Forum Discussion
Calculated Measure for multiple filters
I am trying to total the number of days when a person is absent for both the am and the pm (on the same day) over a period of time based on multiple filters using a number of slicers.
In essence
Person# Date Period Abs Type
1 9/1/2019 am sick
1 9/1/2019 pm sick
2 9/1/2019 am sick
1 9/2/2019 am sick
1 9/3/2019 am personal
1 9/3/2019 pm personal
2 9/3/2019 pm personal
1 9/4/2019 am sick
1 9/5/2019 am sick
1 9/8/2019 am sick
1 9/8/2019 pm sick
2 9/8/2019 pm sick
2 9/9/2019 pm sick
2 9/10/2019 pm sick
I can create a measure to count either the "am" or the "pm" but not both (aka 'and' or '&&').
For example, I can create a measure to count the morning absences.
Person# Date Period Abs Type #absent
1 9/1/2019 am sick 1.0
1 9/2/2019 am sick 1.0
1 9/3/2019 am personal 1.0
1 9/4/2019 am sick 1.0
1 9/5/2019 am sick 1.0
1 9/8/2019 am sick 1.0
___________________________________________________________________
Total 1.0
So I created a new measure
Person# Date #absent
1 9/1/2019 1.0
1 9/3/2019 1.0
1 9/8/2019 1.0
Much appreciated for any thoughts?
Thanks again
2 Replies
- sturlawsResident Rockstar
Hi, SO,
could you try this dax code:
Measure = VAR _am = CALCULATETABLE ( VALUES ( 'Table'[Person#] ); FILTER ( 'Table'; 'Table'[Period] = "am" ) ) VAR _pm = CALCULATETABLE ( VALUES ( 'Table'[Person#] ); FILTER ( 'Table'; 'Table'[Period] = "pm" ) ) RETURN COUNTROWS ( INTERSECT ( _am; _pm ) )Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.- SOHelper III
Dear Strula,
First, I want to thank you very much for responding and being so helpful!
I tried to enter in your code into the measure and I noticed that I needed to convert the ";" to ","s for the code to work.
When I did this, the measure produced a count of 1. I don't think the commas vs semicolons would make a difference in the outcome though?
Second, I should have added that I was looking to count only those days where a person was absent for both the AM and the PM and ignore the days where they were absent in either of the AM or the PM.
Again, thank you for your input and efforts.
Much appreciated.