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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
HYEasterly
Helper I
Helper I

Average versus average based on filter

I need to use the result of a visual matrix to calculate a new column.   The data below is a simplified version of the data I have.  

 

Table A

Fuel TypeGallonsGross Cost
Diesel Regular                          126.76                417.04
Diesel Premium                          305.00

           1,238.30

Unleaded Regular                          508.00            1,452.88
Unleaded Premium                          653.00            2,148.37
Diesel Regular                          350.00            1,106.00
Diesel Premium                          250.00                972.50
Unleaded Regular                          268.00                828.12
Unleaded Premium                          186.00                717.96

 

Table B

Fuel TypePreferred Fuel Type
Diesel RegularDiesel Regular
Diesel PremiumDiesel Regular
Unleaded RegularUnleaded Regular
Unleaded PremiumUnleaded Regular

 

First desired result is:

Fuel TypeSum of GallonsSum of Gross CostAvg Cost/Gal
Diesel Premium5552210.8                 3.98
Diesel Regular476.761523.0404                 3.19
Unleaded Premium8392866.33                 3.42
Unleaded Regular7762281                 2.94
 Total2646.768881.1704                 3.36

 

I want it to take the average cost per gallon determined from this visual and add a column that shows what the cost would be if they had purchased the preferred fuel type.

 

Final Desired Result 

Fuel TypeSum of GallonsSum of Gross CostAvg Cost/GalCost w/Pref Fuel
Diesel Premium5552210.8                 3.98    1,772.98
Diesel Regular476.761523.0404                 3.19   1523.04
Unleaded Premium8392866.33                 3.42    2,466.18
Unleaded Regular7762281                 2.94   2281.00
 Total2646.768881.1704                 3.36    8,043.21

 

 

I have tried multiple ways and am not getting it to work.  Basically need to show them what it would cost if they didn't purchase the premium fuel.

5 REPLIES 5
lbendlin
Super User
Super User

lbendlin_0-1743024159128.png

 

Thank you! This has gotten me very close.  Will you look at my formula and tell me why I am getting inaccurate results?

HYEasterly_0-1743104820590.png

If I remove the word SUM on line 4 it gets much closer... but still not correct.

 

HYEasterly_1-1743104874151.png

I am sure it is something very simple that I am missing... but I have been looking at it all day and can't see what it is.

 

Your help is much appreciated!

did you rename the [Units]  field to "Gallons"  for the visual or are these different fields?

Yes, I renamed it for the visual.

no idea. Would be best if you could provide more realistic sample data

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

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.