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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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 Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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