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
dazzer360
Frequent Visitor

Cumulative Average affected by table filter

Hi,

 

I am trying to get my head around the below table behaviour:

Essentially I need the weekly average of the data but then also the cumulative average, this appears to be fine if I select a specific category:

dazzer360_2-1624979798373.png

However when I then include multiple categories incorrect averages are then given for both categories:

 

dazzer360_1-1624979700503.png

 

This is the DAX I am using (I convert to HH:MM:SS in a seperate measure)

 

A2H_Avg_Year_To_Date =
CALCULATE(
AVERAGE(Assignments_Detail[A2H_Secs]),
FILTER(
ALLSELECTED(Assignments_Detail),Assignments_Detail[RespDateDestination] <= MAX(Assignments_Detail[RespDateDestination])
))
 
I've tried a number of different things but I can't work out what I need to do so any help would be appreciated!
3 REPLIES 3
AlexisOlson
Super User
Super User

This is because the ALLSELECTED removes the category context. I'd try making the ALLSELECTED more targeted by referencing just the date column rather than the whole table.

 

A2H_Avg_Year_To_Date =
CALCULATE (
    AVERAGE ( Assignments_Detail[A2H_Secs] ),
    FILTER (
        ALLSELECTED ( Assignments_Detail[RespDateDestination] ),
        Assignments_Detail[RespDateDestination]
            <= MAX ( Assignments_Detail[RespDateDestination] )
    )
)

Hi,

 

Thank you for you reply. Unfortunately that leads to the situation where every Week Ending column gives the same average and it basically seems like it isnt doing the cumulative bit:

dazzer360_1-1624983340109.png

Do you have any other ideas?

I'd have expected that to work if [RespDateDestination] is the column you are using for the date column headers in your visual. If it's not, then whatever dimension you are using there should be in ALLSELECTED instead.

 

I suppose you can approach it from the other side by adding back in the context you do want, though this isn't quite convenient if you want to use a different dimension for your row headers.

 

A2H_Avg_Year_To_Date =
CALCULATE (
    AVERAGE ( Assignments_Detail[A2H_Secs] ),
    VALUES ( Assignments_Detail[Category] ),
    FILTER (
        ALLSELECTED ( Assignments_Detail ),
        Assignments_Detail[RespDateDestination]
            <= MAX ( Assignments_Detail[RespDateDestination] )
    )
)

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.

Top Solution Authors