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

Slicing a measure of summarized data

I am stuck on a measure which won't slice. The measure uses SUMMARIZECOLUMNS and I can get the number exprected, but when I apply a slicer it doesn't filter. 

 

ResponderVariableResponseWeightingCountry
55111.02UK
55221.02UK
55331.02UK
55411.02UK
55521.02UK
56130.99USA
56210.99USA
56340.99USA
56420.99USA
56510.99USA
57110.85UK
57210.85UK
57310.85UK
57440.85UK
57540.85UK

 

For each responder with a response of 1 or 2, return the distinct responder and weighting:

 

ResponderWeightingCountry
570.85UK
551.02UK
560.99USA

 

Then SUM = 2.86

 

Measure:

 

newwmeasure =
var sumtab =
SUMMARIZECOLUMNS(
'Sheet1'[Responder],
'Sheet1'[Weighting],
FILTER(Sheet1,Sheet1[Variable] in {1,2}),
"Weighted",
SUM(Sheet1[Weighting]) / COUNT(Sheet1[Weighting])
)
return sum([Weighted])
 
Gives me the total, but I can't use a slicer for the country and I don't want to create extra tables in the model. 
 
Any help would be appreciated.
 
Thanks
1 ACCEPTED SOLUTION
daxer-almighty
Solution Sage
Solution Sage

SUMMARIZECOLUMNS is a function to be used ONLY for queries, not for measures. https://dax.guide/summarizecolumns 

 

This function does not respect context transition, hence using it in measures does not make any sense.

 

Here's probably what you want:

[Your Measure] =
CALCULATE(
    SUMX(
        summarize(
            T,
            T[Responder],
            T[Weighting]
        ),
        T[Weighting]
    ),
    KEEPFILTERS( 
        // You say in the text you want
        // to filter by Respose, not by
        // Variable (but your formula filters
        // by Variable for some reason).
        T[Response] in {1, 2} 
    )
)

View solution in original post

2 REPLIES 2
daxer-almighty
Solution Sage
Solution Sage

SUMMARIZECOLUMNS is a function to be used ONLY for queries, not for measures. https://dax.guide/summarizecolumns 

 

This function does not respect context transition, hence using it in measures does not make any sense.

 

Here's probably what you want:

[Your Measure] =
CALCULATE(
    SUMX(
        summarize(
            T,
            T[Responder],
            T[Weighting]
        ),
        T[Weighting]
    ),
    KEEPFILTERS( 
        // You say in the text you want
        // to filter by Respose, not by
        // Variable (but your formula filters
        // by Variable for some reason).
        T[Response] in {1, 2} 
    )
)

Thank you @daxer-almighty, it works perfectly 👍

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