PaulR17
2 years agoFrequent Visitor
Countax giving wrong total
Hi,
I am going round and round in circles trying to calculate the number of "off" days for today in the cuurent week for following table:
This is my measure, but it returns the total number of rows that are marked "Current Week" and not just the ones showing "off" on the selected day.
Elstree 2Week Days Off =
VAR ThisDay = FORMAT( TODAY(), "ddd" )
VAR ColumnDay = IF( ThisDay = "Mon", CALCULATE( COUNTAX( Elstree2weekShifts, Elstree2weekShifts[Mon] = "off" ), Elstree2weekShifts[Current Week] = "Current Week" ),
IF( ThisDay = "Tue", CALCULATE( COUNTAX( Elstree2weekShifts, Elstree2weekShifts[Tue] = "off" ), Elstree2weekShifts[Current Week] = "Current Week" ),
IF( ThisDay = "Wed", CALCULATE( COUNTAX( Elstree2weekShifts, Elstree2weekShifts[Wed] = "off" ), Elstree2weekShifts[Current Week] = "Current Week" ),
IF( ThisDay = "Thu", CALCULATE( COUNTAX( Elstree2weekShifts, Elstree2weekShifts[Thu] = "off" ), Elstree2weekShifts[Current Week] = "Current Week" ),
IF( ThisDay = "Fri", CALCULATE( COUNTAX( Elstree2weekShifts, Elstree2weekShifts[Fri] = "off" ), Elstree2weekShifts[Current Week] = "Current Week" ),
IF( ThisDay = "Sat", CALCULATE( COUNTAX( Elstree2weekShifts, Elstree2weekShifts[Sat] = "off" ), Elstree2weekShifts[Current Week] = "Current Week" ),
IF( ThisDay = "Sun", CALCULATE( COUNTAX( Elstree2weekShifts, Elstree2weekShifts[Sun] = "off" ), Elstree2weekShifts[Current Week] = "Current Week" )
)))))))
RETURN
ColumnDay
Any help would be greatly appreciated.
Thank you
OK, problem solved. It was COUNTAX that was causing the problem. Substituting with CALCULATE and COUNTROWS gives the correct answer.
Thanks very much for your help, the FILTER was essential.
Elstree 2Week Days Off =VAR ThisDay = FORMAT(TODAY(), "ddd")RETURNCALCULATE(COUNTROWS(FILTER( Elstree2weekShifts, Elstree2weekShifts[Current Week] = "Current Week" ) ),SWITCH( ThisDay,"Mon", Elstree2weekShifts[Mon],"Tue", Elstree2weekShifts[Tue],"Wed", Elstree2weekShifts[Wed],"Thu", Elstree2weekShifts[Thu],"Fri", Elstree2weekShifts[Fri],"Sat", Elstree2weekShifts[Sat],"Sun", Elstree2weekShifts[Sun] ) = "off" )