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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Sum by grouped fields

Hello guys,

 

I have two tables (Model and Ocurrencies) and I wish to create two measures which sum the mileages of models by the unit field.  In addition, these two tables have a relationship. However, on the Ocurrencies table, the registers must be grouped by the model and month so that distinct registers are considered. Below are my data:

 

Model table:

ModelMileageUnit
Area 117000KM2
Area 2265,1KM
Area 356,09KM

 

Ocurrencies table:

ModelMonth
Area 1January
Area 1January
Area 1January
Area 1February
Area 2January
Area 2January
Area 3March
Area 3March
Area 3April

 

Result when unit equal "KM2":  
ModelMonthMileage
Area 1January17000
Area 1February17000

 

Result of the sum measure when unit equal "KM2"
34000

 

Result when unit equal "KM":  
ModelMonthMileage
Area 2January265,1
Area 3March56,09
Area 3April56,09

 

Result of the sum measure when unit equal "KM"
377,28

 

Thank you so much for your help!!

 

Best wishes,

Gustavo Xerez

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a measure as follows:

Measure = 
IF(ISINSCOPE('Model'[Model]), 
  CALCULATE( SUM('Model'[Mileage]),FILTER('Ocurrencies',[Month]=MAX('Ocurrencies'[Month]))),
  SUMX(SUMMARIZE('Ocurrencies',[Model],[Month],"1",SUM('Model'[Mileage])),[1]))

The final output is shown below:

vyalanwumsft_0-1647330294599.pngvyalanwumsft_1-1647330311476.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a measure as follows:

Measure = 
IF(ISINSCOPE('Model'[Model]), 
  CALCULATE( SUM('Model'[Mileage]),FILTER('Ocurrencies',[Month]=MAX('Ocurrencies'[Month]))),
  SUMX(SUMMARIZE('Ocurrencies',[Model],[Month],"1",SUM('Model'[Mileage])),[1]))

The final output is shown below:

vyalanwumsft_0-1647330294599.pngvyalanwumsft_1-1647330311476.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @v-yalanwu-msft,

 

Thanks a lot for your help !! I wish to know how to create these two measures as you have done so that one returns the sum when the unit is "KM" and the other one when the unit is "KM2". Both of them will not need a selection of KM or KM2.

 

Thanks in advance.

 

Best regards,

Gustavo Xerez

amitchandak
Super User
Super User

@Anonymous , One to many join between Model  and Ocurrencies

 

Then a measure like 

 

Sumx(Ocurrencies, related(Model[Mileage])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak, I have created a measure as you described and unfortunately, it didn´t work. I put the measure in a card and the sum return 68.698,47 using the same data of the post.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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