Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Input:
Category1 | Category2 | Count |
A | 1 | 100 |
A | 2 | 50 |
B | 1 | 200 |
B | 2 | 400 |
B | 3 | 100 |
B | 4 | 300 |
C | 1 | 300 |
C | 2 | 200 |
C | 3 | 100 |
Expected Output:
Category1 | Category2 | Count | SUM(Category2 =2) | Comp |
A | 1 | 100 | 50 | High |
A | 2 | 50 | 50 | Equal |
B | 1 | 200 | 400 | Low |
B | 2 | 400 | 400 | Equal |
B | 3 | 100 | 400 | Low |
B | 4 | 300 | 400 | Low |
C | 1 | 300 | 200 | High |
C | 2 | 200 | 200 | Equal |
C | 3 | 100 | 200 | Low |
Tried:
Solved! Go to Solution.
Hello rp2022,
Try this for your Category 2 is 2 measure:
Category 2 is 2 Total =
VAR Cat1 = SELECTEDVALUE ( 'Table'[Category1] )
VAR Filtered =
FILTER (
ALL ( 'Table' ),
'Table'[Category2] = 2 &&
'Table'[Category1] = Cat1
)
VAR Result =
SUMX (
Filtered,
'Table'[Count]
)
RETURN Result
and try this for your Comp measure:
Comp =
VAR SumCount = SUM ( 'Table'[Count] )
VAR CompValue = [Category 2 is 2 Total]
VAR CompVar = SumCount - CompValue
VAR Result =
SWITCH (
TRUE(),
CompVar > 0, "High",
CompVar = 0, "Equal",
CompVar <= 0, "Low"
)
RETURN IF ( ISINSCOPE ( 'Table'[Category1] ), Result )
This is what I get when I tested it with your sample data:
----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)
Proud to be a Super User! | |
Your Sum2 is what I tried first but for some reason, it didn't work for me. 😅 Your Comp measure is definitely more succinct though! 😄
You also just have the one table of data right?
Proud to be a Super User! | |
You probably tried it as a measure.
Of course, they worked for me when they are both measures
Hello rp2022,
Try this for your Category 2 is 2 measure:
Category 2 is 2 Total =
VAR Cat1 = SELECTEDVALUE ( 'Table'[Category1] )
VAR Filtered =
FILTER (
ALL ( 'Table' ),
'Table'[Category2] = 2 &&
'Table'[Category1] = Cat1
)
VAR Result =
SUMX (
Filtered,
'Table'[Count]
)
RETURN Result
and try this for your Comp measure:
Comp =
VAR SumCount = SUM ( 'Table'[Count] )
VAR CompValue = [Category 2 is 2 Total]
VAR CompVar = SumCount - CompValue
VAR Result =
SWITCH (
TRUE(),
CompVar > 0, "High",
CompVar = 0, "Equal",
CompVar <= 0, "Low"
)
RETURN IF ( ISINSCOPE ( 'Table'[Category1] ), Result )
This is what I get when I tested it with your sample data:
----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)
Proud to be a Super User! | |
Thank you so much, it worked like a charm
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
144 | |
85 | |
65 | |
51 | |
45 |
User | Count |
---|---|
217 | |
88 | |
81 | |
65 | |
56 |