Forum Discussion
DAX Calculation (Row by Row Division)
- 1 year ago
Create a DAX measure to calculate the ratio by dividing the responseCount of headerString A by headerString B for each institution.
Institution Ratio =
VAR responseA =
CALCULATE(
SUM('Table'[responseCount]),
'Table'[headerString] = "A"
)
VAR responseB =
CALCULATE(
SUM('Table'[responseCount]),
'Table'[headerString] = "B"
)
RETURN
IF(responseB = 0, BLANK(), responseA / responseB)- The measure first calculates the sum of responseCount for headerString A and headerString B within the selected filter context (by institution_name).
- Then it divides the result for headerString A by the result for headerString B.
- It checks if the denominator (responseB) is zero to avoid division errors, returning BLANK() when there's no valid data.
You can place this measure in a table visualization with institution_name to see the ratios for each institution.
Create a DAX measure to calculate the ratio by dividing the responseCount of headerString A by headerString B for each institution.
Institution Ratio =
VAR responseA =
CALCULATE(
SUM('Table'[responseCount]),
'Table'[headerString] = "A"
)
VAR responseB =
CALCULATE(
SUM('Table'[responseCount]),
'Table'[headerString] = "B"
)
RETURN
IF(responseB = 0, BLANK(), responseA / responseB)
- The measure first calculates the sum of responseCount for headerString A and headerString B within the selected filter context (by institution_name).
- Then it divides the result for headerString A by the result for headerString B.
- It checks if the denominator (responseB) is zero to avoid division errors, returning BLANK() when there's no valid data.
You can place this measure in a table visualization with institution_name to see the ratios for each institution.