Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello, I would like to create a measure in DAX to calculate Percent of CAB and CAN for the specified rows.
I marked with blue CAB and with green CAN. This needs to be dynamic because there is a hierarchy on Level 1(every row is splited on other 3 types).
Thank you!
Solved! Go to Solution.
Hi @Anonymous
Here's a measure that gets you the results in Column E of your screenshot. I didn't quite follow what you meant by 'hierarchy on Level 1' but hopefully this works.
% of CAB/CAN =
VAR _Level1 = SELECTEDVALUE('Table'[Level 1])
VAR _CABCAN =
IF(_Level1 <= "06",
CALCULATE(SUM('Table'[Amount]), 'Table'[Level 1] = "01. CAB - CIFRA DE AFACERI BRUTA"),
CALCULATE(SUM('Table'[Amount]), 'Table'[Level 1] = "06. CAN - CIFRA DE AFACERI NETA")
)
VAR _Result =
DIVIDE(SUM('Table'[Amount]), _CABCAN)
RETURN
_Result
Notice you're getting a result on the total line. You may want to stop that by returning
Hi, Again! What I wanted to say about Hierarchy is something like this:
Every row in level 1 has other rows in other Levels. Level 2, for example is a split between Reatil and Online. Then Retail will be splited in level 3 in other types and so on.
Hi @Anonymous
Here's a measure that gets you the results in Column E of your screenshot. I didn't quite follow what you meant by 'hierarchy on Level 1' but hopefully this works.
% of CAB/CAN =
VAR _Level1 = SELECTEDVALUE('Table'[Level 1])
VAR _CABCAN =
IF(_Level1 <= "06",
CALCULATE(SUM('Table'[Amount]), 'Table'[Level 1] = "01. CAB - CIFRA DE AFACERI BRUTA"),
CALCULATE(SUM('Table'[Amount]), 'Table'[Level 1] = "06. CAN - CIFRA DE AFACERI NETA")
)
VAR _Result =
DIVIDE(SUM('Table'[Amount]), _CABCAN)
RETURN
_Result
Notice you're getting a result on the total line. You may want to stop that by returning
Thank you, Paul! Is what I wanted!
I liked your idea with <="6"
Hi, Adrian.
Hmm, I think you should create two diferent measures with these formula:
I really hope I help you
Regards from Brazil!
Hello, Henrique! This is also helpfull. Thank you!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
8 |
User | Count |
---|---|
13 | |
12 | |
11 | |
10 | |
8 |