Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
esingh
Helper I
Helper I

DAX Calculation (Row by Row Division)

Hi 

 

I am new to Power BI and facing issues to create a dax calculation to achieve the following result:

Based on filter selection on ID,  headerString we need to compute the ratio. The ratio are to be calculated based on each institution name. (Refer the table below)

e.g For ABC Insitute we need to divide the response count of header string A for id 6 with Response count of header string B for id 6 .i.e 1401233/59 for ABC and similarly 1401000/54 for DEF etc. 

 

Thanks 

Ekam

idcategoryCodeoptionStringheaderStringresponseStringresponseCountinstitution_nameinstitution_code
6POST A 1401233ABC10
6POST A 1401000DEF20
6POST A 0GHI30
6POST A 0JKL40
6POST B 59ABC10
6POST B 53DEF20
6POST B 0GHI30
6POST B 0JKL

40

1 ACCEPTED SOLUTION
123abc
Community Champion
Community Champion

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.

View solution in original post

2 REPLIES 2
esingh
Helper I
Helper I

Thanks.. Just one more clarification.. we can even add [id] in the filter condition to get the values if ids are different.

123abc
Community Champion
Community Champion

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.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.