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.
Hi all!
I have the following table as a data source in Power BI:
What I want to do is to see how many unique combinations of categories are there within all groups and sum them up by category. For example, category 3 has 4 total combinations across all groups (0 in group 1 + 2 in group 2 (with categories 1 and 2) + 2 in group 3 (with categories 1 and 2) = 4 combinations in total).
In the end, I want a table that looks like this:
Have been testing various DAX functions in order to achieve that result, but no luck.
Would greatly appreciate your help!
Solved! Go to Solution.
Hi, @dmitry-wbr
Please try the below measure.
Count measure =
VAR currentcategory =
MAX ( 'Table'[Category] )
VAR includingcurrentcategory =
VALUES ( 'Table'[Group] )
VAR newtable =
SUMMARIZE (
FILTER (
ALL ( 'Table' ),
'Table'[Group]
IN includingcurrentcategory
&& 'Table'[Category] <> currentcategory
),
'Table'[Group],
'Table'[Category]
)
RETURN
SUMX ( newtable, 1 )
Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
Linkedin: https://www.linkedin.com/in/jihwankim1975/
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, @dmitry-wbr
Please try the below measure.
Count measure =
VAR currentcategory =
MAX ( 'Table'[Category] )
VAR includingcurrentcategory =
VALUES ( 'Table'[Group] )
VAR newtable =
SUMMARIZE (
FILTER (
ALL ( 'Table' ),
'Table'[Group]
IN includingcurrentcategory
&& 'Table'[Category] <> currentcategory
),
'Table'[Group],
'Table'[Category]
)
RETURN
SUMX ( newtable, 1 )
Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
Linkedin: https://www.linkedin.com/in/jihwankim1975/
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.
@dmitry-wbr , Try a measure like
sumx(values(Table[category]), calculate(distinctCOUNT(Table[group])))
Hi, @amitchandak
Thanks for the reply! Unfortunately, your formula gives incorrect results. Here is the resulting output (should be 5 for categories 1,2 and 4 for category 3):
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
49 | |
25 | |
20 | |
15 | |
12 |
User | Count |
---|---|
57 | |
49 | |
44 | |
18 | |
18 |