How to calculate the sum of a ratio where each row s numerator and denominator depend on a third column

0 votes

How to calculate the sum of a ratio where each row’s numerator and denominator depend on a third column?

In Power BI, I need to calculate a total by summing up row-level ratios. However, both the numerator and denominator for each ratio depend on a value from a third column. I need help designing a DAX measure or calculated column that correctly computes and aggregates these ratios.

8 hours ago in Power BI by Evanjalin
• 34,450 points
6 views

1 answer to this question.

0 votes

Assume:

  • Numerator is used when Type = "A"

  • Denominator is used when Type = "B"

Create two helper columns first (optional but clearer):

NumeratorValue = IF(YourTable[Type] = "A", YourTable[Value], BLANK())
DenominatorValue = IF(YourTable[Type] = "B", YourTable[Value], BLANK())

Now create the Ratio Column per row:

RowRatio =
VAR Num = CALCULATE(SUM(YourTable[Value]), FILTER(YourTable, YourTable[ID] = EARLIER(YourTable[ID]) && YourTable[Type] = "A"))
VAR Den = CALCULATE(SUM(YourTable[Value]), FILTER(YourTable, YourTable[ID] = EARLIER(YourTable[ID]) && YourTable[Type] = "B"))
RETURN
DIVIDE(Num, Den)

Then create a measure to sum all valid row-level ratios:

TotalRatioSum = SUMX(YourTable, YourTable[RowRatio])

answered 8 hours ago by anonymous
• 34,450 points

Related Questions In Power BI

0 votes
1 answer

In DAX, how do I RETURN the sum of a calculated column from a DAX Table Variable (created via ADDCOLUMN)?

You can access column variables of previously ...READ MORE

answered Oct 8, 2020 in Power BI by Gitika
• 65,730 points
4,946 views
0 votes
1 answer

How to Toggle Between Two Option and Make it Interact with the rest of the Visualizations in a Report?

Toggling is an action that is achieved ...READ MORE

answered Oct 20, 2020 in Power BI by anonymous
• 65,730 points
1,365 views
0 votes
2 answers

How can I set up cascading slicers in Power BI, where one slicer’s options depend on the selection of another?

Use the dependent slicers by making a ...READ MORE

answered Jan 23 in Power BI by anonymous
• 24,450 points
445 views
+1 vote
2 answers
0 votes
1 answer

Displaying Table Schema using Power BI with Azure IoT Hub

Answering your first question, Event Hubs are ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by nirvana
• 3,090 points
1,802 views
+1 vote
1 answer

Unable to install connector for Power Bi and PostgreSQL

I think the problem is not at ...READ MORE

answered Aug 22, 2018 in Power BI by nirvana
• 3,090 points
3,168 views
+2 votes
2 answers

Migrate power bi collection to power bi embedded

I agree with Kalgi, this method is ...READ MORE

answered Oct 11, 2018 in Power BI by Hannah
• 18,520 points
1,969 views
+1 vote
1 answer

Connect power bi desktop to dataset and create custom reports

Open power bi report nd sign in ...READ MORE

answered Oct 10, 2023 in Power BI by Monika kale

edited Mar 5 2,164 views
0 votes
1 answer

I need to calculate a running total but reset it at the start of each new quarter—how can I achieve this in DAX?

To calculate a running total that resets ...READ MORE

answered Mar 7 in Power BI by anonymous
• 34,450 points
296 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP