5 Replies Latest reply: Oct 23, 2018 12:39 PM by Vegar Lie Arntsen

# help me with chart percentage calculation

hi ,

i make a chart to calculate the percentage of how much the machine work in 24 h , but i want to make a condition if the day is saturday , i want just the percentage of 4 h not 24h .

thank you

• ###### Re: help me with chart percentage calculation

I guess the easiest way I think is..

If you have a master calendar then you may also have a field Week Day in it.

If you don;t then create 1

MasterCalendar:

if([Week Day]='Sat',1,0) as SatFlag;

weekDay(TempDate) as [Week Day]

...

...

From....

and in front end maybe use

Sum(amount)

/

(if([Week Day]='Sat',

sum({< SatFlag={1}, Hour= {4}  >}Amout) ,

Sum(Amount)))

This may work if you have an Hour field where you can hard code 4

• ###### Re: help me with chart percentage calculation

Why not create the the column while loading in the script? i.e the column will contain either 24 or 4

if(weekday(your_datecolumn)='Sun' or weekday(your_datecolumn)='Sat' ,4,24) as Num_Hours_Counted_PerDay

• ###### Re: help me with chart percentage calculation

A quick solution could be using an expression like this:

sum(Duration) / if(Weekday=6,4/24,1)

• ###### Re: help me with chart percentage calculation

thanks guys ; im very grateful