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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
HYEasterly
New Contributor II

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
Esteemed Contributor III

lbendlin_0-1743024159128.png

 

HYEasterly
New Contributor II

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!

lbendlin
Esteemed Contributor III

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

HYEasterly
New Contributor II

Yes, I renamed it for the visual.

lbendlin
Esteemed Contributor III

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

 

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.

Top Solution Authors
Users online (14,768)