Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Mark_Clipsham
Frequent Visitor

Calculate with Mutliple Filters Not working

Hi,

 

I have a table which I am trying to summarize into another table using a series of calculate functions which apply various filters, however the filters appear to not be working. 

 

My current code: 

 

Table 1: 

 

Mark_Clipsham_0-1602752334153.png

 

Code for Table 2:

 

 

STD Attendance % = 
SUMMARIZE('Attendance Calcs',
    'Attendance Calcs'[school_student_id],
    "Total Pos Days HT 1 20/21", CALCULATE(
                            SUM('Attendance Calcs'[Value]), FILTER('Attendance Calcs', 'Attendance Calcs'[Attendance Classification] = "In" || 'Attendance Calcs'[Attendance Classification] = "Out" && 'Attendance Calcs'[Week] = "2020/21 Week 1" || 'Attendance Calcs'[Week] = "2020/21 Week 2" || 'Attendance Calcs'[Week] = "2020/21 Week 3" || 'Attendance Calcs'[Week] = "2020/21 Week 4" || 'Attendance Calcs'[Week] = "2020/21 Week 5" || 'Attendance Calcs'[Week] = "2020/21 Week 6" || 'Attendance Calcs'[Week] = "2020/21 Week 7" || 'Attendance Calcs'[Week] = "2020/21 Week 8")),
    "Total Days In HT 1 20/21", CALCULATE(
                            SUM('Attendance Calcs'[Value]), FILTER('Attendance Calcs', 'Attendance Calcs'[Attendance Classification] = "In" && 'Attendance Calcs'[Week] = "2020/21 Week 1" || 'Attendance Calcs'[Week] = "2020/21 Week 2" || 'Attendance Calcs'[Week] = "2020/21 Week 3" || 'Attendance Calcs'[Week] = "2020/21 Week 4" || 'Attendance Calcs'[Week] = "2020/21 Week 5" || 'Attendance Calcs'[Week] = "2020/21 Week 6" || 'Attendance Calcs'[Week] = "2020/21 Week 7" || 'Attendance Calcs'[Week] = "2020/21 Week 8")))

 

 

Out put of table 2:

 

Mark_Clipsham_1-1602752470053.png

 

So it is clear the functions are disregarding the filters and just summing the entire table but I'm not sure why this is happening?

 

Advice would be greatly appreciated!

 

Thanks,

 

1 ACCEPTED SOLUTION

Hi @Mark_Clipsham ,

You can create two measures as below to get them:

Total Pos Days HT 1 20/21 = 
CALCULATE (
    SUM ( 'Attendance Calcs'[Value] ),
    FILTER (
        'Attendance Calcs',
         'Attendance Calcs'[Attendance Classification] in { "In", "Out"}
            && 'Attendance Calcs'[Week]
            IN {
            "2020/21 Week 1",
            "2020/21 Week 2",
            "2020/21 Week 3",
            "2020/21 Week 4",
            "2020/21 Week 5",
            "2020/21 Week 6",
            "2020/21 Week 7",
            "2020/21 Week 8"
        }
    )
)
Total Days HT 1 20/21 = 
CALCULATE (
    SUM ( 'Attendance Calcs'[Value] ),
    FILTER (
        'Attendance Calcs',
        'Attendance Calcs'[Attendance Classification] = "In"
            && 'Attendance Calcs'[Week]
            IN {
            "2020/21 Week 1",
            "2020/21 Week 2",
            "2020/21 Week 3",
            "2020/21 Week 4",
            "2020/21 Week 5",
            "2020/21 Week 6",
            "2020/21 Week 7",
            "2020/21 Week 8"
        }
    )
)

Calculate with Mutliple Filters Not working.JPG

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @Mark_Clipsham ,

What's the correct value of field [Total Pos Days HT 1 20/21] and [Total Days In HT 1 20/21]? Could you please provide their calcuation logic?

Total Pos Days HT 1 20/21= the total values which the attendance classification is ( "IN" or "OUT") and week in 2020/21 week 1~week 8  ?
Total Days In HT 1 20/21= the total values which the attendance classification is "IN" and week in 2020/21 week 1~week 8  ?

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Rena, 

 

Yes you've got that correct.

 

The logic is that 'Total Pos Days HT 1 20/21' would equal the sum of the value column for all rows where 'Attendance Classification' = IN or OUT and 'Week' = 2020/21 Week 1 to Week 8.

 

Then 'Total Days In HT 1 20/21' would be the same but 'Attendance Classification' = IN only.

 

So in this scenario:

 

' Total Pos Days HT 1 20/21'  = 12
'Total Days HT 1 20/21' = 10

 

Hope that makes sense,

Thanks,

Hi @Mark_Clipsham ,

You can create two measures as below to get them:

Total Pos Days HT 1 20/21 = 
CALCULATE (
    SUM ( 'Attendance Calcs'[Value] ),
    FILTER (
        'Attendance Calcs',
         'Attendance Calcs'[Attendance Classification] in { "In", "Out"}
            && 'Attendance Calcs'[Week]
            IN {
            "2020/21 Week 1",
            "2020/21 Week 2",
            "2020/21 Week 3",
            "2020/21 Week 4",
            "2020/21 Week 5",
            "2020/21 Week 6",
            "2020/21 Week 7",
            "2020/21 Week 8"
        }
    )
)
Total Days HT 1 20/21 = 
CALCULATE (
    SUM ( 'Attendance Calcs'[Value] ),
    FILTER (
        'Attendance Calcs',
        'Attendance Calcs'[Attendance Classification] = "In"
            && 'Attendance Calcs'[Week]
            IN {
            "2020/21 Week 1",
            "2020/21 Week 2",
            "2020/21 Week 3",
            "2020/21 Week 4",
            "2020/21 Week 5",
            "2020/21 Week 6",
            "2020/21 Week 7",
            "2020/21 Week 8"
        }
    )
)

Calculate with Mutliple Filters Not working.JPG

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thats worked perfectly, thanks Rena.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.