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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculate average and sum based on unique combination of other columns

Hi all,

 

I need to calculate the emission which is Propulsion / Distance. Quite is easy however 2 other calculations are nessecary which I could use your help with. 

1. Average of Distance: Every row has a duplictae due to the fuel type. This cannot be removed by simply removing the duplicates because propulsion has a unique value. I was thinking of calculating the average of distance based on the unique combination of Code, Name, Voyage No, report type and report date using distinct but so far had no succes. 

 

2. Sum of Propulsion: same as above but now sum instead of average. 

 

Below grid is an example of the data:

 

CodeNameVoyage NoReport TypeReport Date GmtDistanceFuel TypePropulsion
2011Gal19001Noon Report31-01-2019 16:59204HFO9.41
2011Gal19001Noon Report31-01-2019 16:59204MGO0.00
2011Gal19001End of Leg Report31-01-2019 21:4872HFO2.36
2011Gal19001End of Leg Report31-01-2019 21:4872MGO0.00
2011Gal19002Noon Report02-02-2019 05:0098HFO3.23
2011Gal19002Noon Report02-02-2019 05:0098MGO1.22
2011Gal19002Noon Report03-02-2019 04:00311HFO3.34
2011Gal19002Noon Report03-02-2019 04:00311MGO12.10
2011Gal19002End of Leg Report03-02-2019 09:4281HFO1.20
2011Gal19002End of Leg Report03-02-2019 09:4281MGO2.69
2011Gal19002Noon Report04-02-2019 04:00117HFO2.60
2011Gal19002Noon Report04-02-2019 04:00117MGO1.20
2011Gal19002Noon Report05-02-2019 04:00395HFO16.85
2011Gal19002Noon Report05-02-2019 04:00395MGO0.00

 

So eventually it should show the below result:

CodeNameVoyage NoReport TypeReport Date GmtDistanceFuel TypePropulsion
2011Gal19001Noon Report31-01-2019 16:59204HFO9.41
2011Gal19001End of Leg Report31-01-2019 21:4872HFO2.36
2011Gal19002Noon Report02-02-2019 05:0098HFO/MGO4.45

 

Hope someone can help out!

 

Many thanks, 

 

Sharon

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try to check this

sumx(summarize(Table, [Code], [Name], [Voyage No],[report type],[report date], [Distance]),[Distance])

View solution in original post

2 REPLIES 2
ryan_mayu
Super User
Super User

@Anonymous 

please check if the attachment is what you want.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous , Try to check this

sumx(summarize(Table, [Code], [Name], [Voyage No],[report type],[report date], [Distance]),[Distance])

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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