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

Measure - Filter / Table / Summarizecolumns help needed

Hello

I struggle on trying to achieve the following behavior in coding the right formula in a Measure of my PBI

Example - Table is

 

MarketCountryTypeValue
BNLNLXmas3
BNLBEXmas4
BNLLUXmas5
FRFRXmas6
BNLNLSales7
BNLBESales8
BNLLUSales9
FRFRSales10

 

I have this formula (Measure)

"Nb Countries Distinct selected" = COUNTROWS(SUMMARIZECOLUMNS(Table[Country], FILTER(Table, Table[Type] = "Xmas")))

(user will filter the report by Market > for each selection = find the number of distinct countries for Xmas whetever the Type selected = always retrieve this figure and then use it in a measure (whatever Type value selected) = sum (Value) / Nb distinct countries (for Xmas type)

 

It gave good result but when I when to use this calculated measure into another measure (to get the sum Value / nb countries distinct selected) = failed.

 

I tried other stuff but cannot find a way to do so. Any idea ?

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can't use SUMMARIZECOLUMNS in a measure, where you need that functionality you have to use ADDCOLUMNS( SUMMARIZE()), but in this case it isn't necessary. Try

Nb Countries Distinct selected =
COUNTROWS (
    CALCULATETABLE (
        DISTINCT ( 'Table'[Country] ),
        REMOVEFILTERS (),
        'Table'[Type] = "Xmas"
    )
)

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

You can't use SUMMARIZECOLUMNS in a measure, where you need that functionality you have to use ADDCOLUMNS( SUMMARIZE()), but in this case it isn't necessary. Try

Nb Countries Distinct selected =
COUNTROWS (
    CALCULATETABLE (
        DISTINCT ( 'Table'[Country] ),
        REMOVEFILTERS (),
        'Table'[Type] = "Xmas"
    )
)

Great ! Just tweaked removing the Removed Filters but 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