Forum Discussion
mmh9119
2 years agoFrequent Visitor
Calculate values in one measure using DAX
Hi all, Simple issue. I have a percentage calculation measure that I'm using in a Card Visual. The issue is, in order to calculate this percentage, I need to calculate the total in one measure, t...
- 2 years ago
PC_Percentage =
DIVIDE (
CALCULATE (
COUNTROWS ( Table1 ),
FILTER ( ALLSELECTED ( Table1 ), Table1[Jurisd] = "Provincial" )
),
COUNT ( Table1[PersonId] ),
0 -- Add a default value for divide to handle potential division by zero
)
Ced-Alcaraz
2 years agoRegular Visitor
Hi mmh9119 ,
You can use variables in Power BI Measures.
AllInOneMeasure =
var _PC_Total = COUNT(Table1[PersonId])
var _PC_Provincial = CALCULATE(
COUNTROWS(Table1),
FILTER(ALLSELECTED(Table1), Table1[Jurisd] = "Provincial")
)
RETURN
DIVIDE([_PC_Provincial],[_PC_Total],1)