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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
lrockwell
Frequent Visitor

Calculating price per gallon

I have Data from an Excel file.. which i have Merged with Salesforce data. I have other Salesforce data that has Volume added which is a numeric amount referencing how many gallons have been added to the machine. I need to show the $ spend on the fluid by calculating the price per GA times the GA added. How do you go about making it do math? 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

What you need to do is create a Measure to do all of this.  You will need to make use of "SUM" functions to take the aggregate values in the table and arrive a single total figure.  If your pricing information is in a differnet place to your fuel information you will need to make sure your tables are linked.

 

Lastly if your pricing information changes from Time to Time, you will need a Date table that you can leverage off.  Using the Values function you will be able to run your Sums on a period by period basis getting the correct totals for that single period.  This could look like:

 

Fuel Price = if(
	COUNTROWS(values('Dim - Date Table'[YearMonth])) = 1, 
	SUM('FuelTable'[FuelAmount]) * MEDIAN('Pricing Table'[Price]), 
	SUMX(
		VALUES('Dim - Date Table'[YearMonth]), 
		SUM('FuelTable'[FuelAmount]) * MEDIAN('Pricing Table'[Price])
	)
)

This code would be attempting to multiply the sum of fuel of a given month by the median price of that month.  Not the only way to do it, but hopefully enough to give you a picture.

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

What you need to do is create a Measure to do all of this.  You will need to make use of "SUM" functions to take the aggregate values in the table and arrive a single total figure.  If your pricing information is in a differnet place to your fuel information you will need to make sure your tables are linked.

 

Lastly if your pricing information changes from Time to Time, you will need a Date table that you can leverage off.  Using the Values function you will be able to run your Sums on a period by period basis getting the correct totals for that single period.  This could look like:

 

Fuel Price = if(
	COUNTROWS(values('Dim - Date Table'[YearMonth])) = 1, 
	SUM('FuelTable'[FuelAmount]) * MEDIAN('Pricing Table'[Price]), 
	SUMX(
		VALUES('Dim - Date Table'[YearMonth]), 
		SUM('FuelTable'[FuelAmount]) * MEDIAN('Pricing Table'[Price])
	)
)

This code would be attempting to multiply the sum of fuel of a given month by the median price of that month.  Not the only way to do it, but hopefully enough to give you a picture.

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.