1
votes

I have a slicer, called COUNTRY and applied to table MY_TABLE. When I calculate a measure, everything works as expected:

-- calculates distinct count only for COUNTRY = x
Some Measure = DISTINCTCOUNT('MY_TABLE'[SOME_COLUMN])

The problem is SUMMARIZE ignores slicer selection:

-- calculates distinct count accross all countries: x, y, z, etc.
Calculated Table = 
RETURN SUMMARIZE(
    'SOME_TABLE',
    [CATEGORY],
    "COUNT", DISTINCTCOUNT('SOME_TABLE'[SOME_COLUMN])
)

How to make SUMMARIZE take into account slicers?

2
From this thread I understand it's not possible, but still not sure community.powerbi.com/t5/Desktop/…VB_

2 Answers

2
votes

Of course, you can filter calculated table with a slicer. If you can, go for SUMMARIZECOLUMNS because this function is better optimized then SUMMARIZE, and has arguments for filtering.

Filtering SUMMARIZECOLUMNS

If you want to stick to SUMMARIZE, you can filter your table by wrapping it with CALCULATETABLE.

Calculated Table =
CALCULATETABLE (
    SUMMARIZE (
        'SOME_TABLE',
        [CATEGORY],
        "COUNT", DISTINCTCOUNT ( 'SOME_TABLE'[SOME_COLUMN] )
    ),
    Dim[Color]
        = SELECTEDVALUE ( Slicer[SlicerValues] )
)

Should FILTER be used inside or outside of SUMMARIZE?

2
votes

Only Measures are "responsive", calculated tables and columns get calculated and created once, when the data are loaded.

Note that if a calculated table is used inside a measure it will behave correctly, but as you may know, a measure must return a scalar value and not a table. (ie you can use summarize inside a measure, you can then filter the obtained table and return the sum of one column)