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.
Hello,
Let's say I have a data structure like this
Level 1 Level 2 Status
A A1 Approved
A A2 Approved
A A3 Approved
B B1 Review
B B2 Approved
B B3 Review
C C1 Approved
C C2 Approved
C C3 Approved
Only when all items in level 2 are approved, level 1 items are approved. So how do I write a measure to count how many level 1 items are approved?
Thanks for the help in advance!
Solved! Go to Solution.
Hey @glycine76 ,
this measure:
Measure =
COUNTX(
VALUES( 'Status'[Lvl1] )
, var noOfRowsLvl2 =
COUNTROWS(
CALCULATETABLE(
VALUES( 'Status'[Lvl2] )
, ALL( 'Status'[Lvl2] )
, ALL( 'Status'[Status] )
)
)
var noOfRowsApproved =
COUNTROWS(
CALCULATETABLE(
FILTER(
'Status'
, 'Status'[Status] = "Approved"
)
, ALL( 'Status'[Lvl2] )
, ALL( 'Status'[Status] )
)
)
return
IF( noOfRowsLvl2 = noOfRowsApproved , 1 , BLANK() )
)
Allows creating this table visual:
Please be aware that I enabled the option "Show items with no data" on the column Lvl1, this option does not affect the measure, but it helps to understand my sample data, and why Lvl1 = B is not considered "complete".
Hopefully, this provides what you are looking for.
Regards,
Tom
Use the table tool when you are providing simple sample data otherwise it will eat up time from people trying to help:
Hi @glycine76 ,
If you are using matrix, please try:
Measure =
IF (
ISINSCOPE ( 'Table'[Level 2] ),
MAX ( 'Table'[Status] ),
IF (
COUNTROWS ( FILTER ( 'Table', [Status] = "Approved" ) )
= COUNTROWS ( 'Table' ),
"Approved",
"Review"
)
)
Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @glycine76 ,
Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.
Refer to:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you all! Very helpful!
Hi @glycine76 ,
If you are using matrix, please try:
Measure =
IF (
ISINSCOPE ( 'Table'[Level 2] ),
MAX ( 'Table'[Status] ),
IF (
COUNTROWS ( FILTER ( 'Table', [Status] = "Approved" ) )
= COUNTROWS ( 'Table' ),
"Approved",
"Review"
)
)
Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hey @glycine76 ,
this measure:
Measure =
COUNTX(
VALUES( 'Status'[Lvl1] )
, var noOfRowsLvl2 =
COUNTROWS(
CALCULATETABLE(
VALUES( 'Status'[Lvl2] )
, ALL( 'Status'[Lvl2] )
, ALL( 'Status'[Status] )
)
)
var noOfRowsApproved =
COUNTROWS(
CALCULATETABLE(
FILTER(
'Status'
, 'Status'[Status] = "Approved"
)
, ALL( 'Status'[Lvl2] )
, ALL( 'Status'[Status] )
)
)
return
IF( noOfRowsLvl2 = noOfRowsApproved , 1 , BLANK() )
)
Allows creating this table visual:
Please be aware that I enabled the option "Show items with no data" on the column Lvl1, this option does not affect the measure, but it helps to understand my sample data, and why Lvl1 = B is not considered "complete".
Hopefully, this provides what you are looking for.
Regards,
Tom
Use the table tool when you are providing simple sample data otherwise it will eat up time from people trying to help:
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 |
---|---|
113 | |
97 | |
79 | |
73 | |
56 |
User | Count |
---|---|
145 | |
105 | |
104 | |
90 | |
63 |