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
Quinnie2017
Helper II
Helper II

DAX Weighted Average works but does not work as expected with slicer

Hi - I have a DAX weighted average formula that works without a slicer.

 

When I add a slicer for Markets the DAX continues to calculate at the All Markets level versus the market level.

 

Can you help me adjust my DAX to consider the slicer?

 

Weighted Avg Impact =
SUMX(
SUMMARIZE('Day Key','Day Key'[KBP PD]),
DIVIDE(
CALCULATE([Avg Impact]*COUNTA(MASTER[Store]))
,
CALCULATE(COUNT('Cost Center'[Cost_CenterKey]),'Cost Center'[CC Type]="Store")
))
 
Exhibit 1: DAX that works at All Markets level
Quinnie2017_2-1625695716348.png
Exhibit 2: DAX does not adjust to only Atlanta when selecting Atlanta market (still calculates using All Markets)
Quinnie2017_3-1625695735583.png

 

1 REPLY 1
v-janeyg-msft
Community Support
Community Support

Hi, @Quinnie2017 

 

It‘s not clear that the field on the slicer is on which table. You can try to use allselected() function in the formula involving that table.

Like this:

Weighted Avg Impact =
SUMX (
    SUMMARIZE ( ALLSELECTED ( 'Day Key' ), 'Day Key'[KBP PD] ),
    DIVIDE (
        CALCULATE ( [Avg Impact] * COUNTA ( MASTER[Store] ), ALLSELECTED ( 'MASTER' ) ),
        CALCULATE (
            COUNT ( 'Cost Center'[Cost_CenterKey] ),
            'Cost Center'[CC Type] = "Store",
            ALLSELECTED ( 'Cost Center' )
        )
    )
)

[Avg Impact] seems to be a measure, it may also need to change.

If it doesn't solve your problem, Can you share a sample file and feel free to ask me.

 

Best Regards

Janey Guo

 

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

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.