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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
hstgeorge
Helper III
Helper III

Help Needed for Calculation

I have a data set that is set up so that one column contains one of the following:  Gallons, Revenue, Fees, Discount and another column next to it that contains the value.  

 

I would like to divide all of them by gallons except gallons.  I don't want to unpivot my data and am looking for a way to do this either by calculated column or measure.

 

So I want to take total revenue and divide by total gallons and total fees and divid by total gallons, on an on:

 

TypeAmount
GALLONS50
REVENUE200
FEES25
DISCOUNT0.25
GALLONS50
REVENUE200
FEES25
DISCOUNT0.25
1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @hstgeorge 

Here's a sample PBIX with data and DAX Code

Try this measure

 

Ratio = DIVIDE( SUM('Table'[Amount]), CALCULATE( SUM('Table'[Amount]), FILTER(ALL('Table'), 'Table'[Type] = "GALLONS")))

 

You should get this

ratio.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

4 REPLIES 4
PhilipTreacy
Super User
Super User

Hi @hstgeorge 

Here's a sample PBIX with data and DAX Code

Try this measure

 

Ratio = DIVIDE( SUM('Table'[Amount]), CALCULATE( SUM('Table'[Amount]), FILTER(ALL('Table'), 'Table'[Type] = "GALLONS")))

 

You should get this

ratio.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Hello @hstgeorge 
Can you please share the expected output as the description is not very clear?

amitchandak
Super User
Super User

@hstgeorge , Create a measure like

divide(calculate(sum(Table[Amount]), filter(Table, Table[Type] ="GALLONS")),calculate(sum(Table[Amount]), filter(Table, Table[Type] <>"GALLONS")))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

When I type that calc and then use line items in the row to show revenue and then put in the measure so it should divide revenue by gallons, it shows zero or blank but has a value in the total.  Any other suggestions

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.