Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi,
I have a simple table like this:
ID | Cat1 | Cat2 |
1 | A | 01 |
2 | A | 02 |
3 | B | 01 |
4 | C | 01 |
5 | D | 01 |
6 | D | 01 |
I want to view the records where Cat1 has multiple values for Cat2.
Which should look like the following, because only for Cat1 A, Cat2 has multiple values.
ID | Cat1 | Cat2 | Measure |
1 | A | 01 | 1 |
2 | A | 02 | 1 |
3 | B | 01 | 0 |
4 | C | 01 | 0 |
5 | D | 01 | 0 |
6 | D | 01 | 0 |
The following DAX shows the correct COUNT, but when placed in the above table, it shows BLANK values. It does not show 1's or 0's per row. This makes sense, because the measure is on the level of Cat1. How to change the DAX in a way to view 1's and 0's per row on the level of column 'ID'?
COUNTROWS(
FILTER(
ADDCOLUMNS(
SUMMARIZE(
'Table'
,'Table'[Cat1]
)
,"CNT Cat2",CALCULATE(DISTINCTCOUNT('Table'[Cat2]))
),[CNT Cat2] > 1
)
)
I need a measure instead of a calculated column in this model.
Does anyone have any suggestion how to tackle this?
Kind regards,
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
Expected outcome measure: =
VAR _result =
COUNTROWS (
FILTER (
ADDCOLUMNS (
DISTINCT ( 'Table'[Cat1] ),
"@count",
CALCULATE (
COUNTROWS ( DISTINCT ( 'Table'[Cat2] ) ),
ALL ( 'Table'[ID], 'Table'[Cat2] )
)
),
[@count] > 1
)
) > 0
RETURN
IF ( ISINSCOPE ( 'Table'[Cat1] ), DIVIDE ( _result, _result, 0 ) )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi,
Please check the below picture and the attached pbix file.
Expected outcome measure: =
VAR _result =
COUNTROWS (
FILTER (
ADDCOLUMNS (
DISTINCT ( 'Table'[Cat1] ),
"@count",
CALCULATE (
COUNTROWS ( DISTINCT ( 'Table'[Cat2] ) ),
ALL ( 'Table'[ID], 'Table'[Cat2] )
)
),
[@count] > 1
)
) > 0
RETURN
IF ( ISINSCOPE ( 'Table'[Cat1] ), DIVIDE ( _result, _result, 0 ) )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Works like a charm! Nice way of using ISINSCOPE(). Thanks
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
90 | |
84 | |
70 | |
49 |
User | Count |
---|---|
141 | |
121 | |
112 | |
59 | |
58 |