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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Chanleakna123
Post Prodigy
Post Prodigy

Sum Based on Group

hi , 

I have no clue how to Sum each column based on Group, Total Work Hours in MN is where i calculated on Excel Column , 

For Hualage Trucks : Work Hours in MN + Stop Hours in MN 

For Key Account trucks : Idling Hours in MN + Work Hours in MN 

 

How to acheive this on Power BI ? 

 

Groups (groups)Idling Hours in MNWork Hours in MNStop Hours in MNTotal Work Hours In MN
Haulage Trucks30772116888
Haulage Trucks3211491821331
Key Account Trucks53189715242
Key Account Trucks1364061008542
1 ACCEPTED SOLUTION
d_gosbell
Super User
Super User

You could do this by using SUMX to generate a row context, then testing for the value of the Group using an IF or SWITCH statement.

 

So something like the following should work:

 

SUMX( table1 , 
SWITCH( table1[Groups (groups)]
  , "Haulage Trucks", table1[Work Hours in MN] + table1[Stop Hours in MN] 
  , "Key Accounts Trucks",  table1[Idling Hours in MN] + table1[Work Hours in MN] 
  )
)

View solution in original post

1 REPLY 1
d_gosbell
Super User
Super User

You could do this by using SUMX to generate a row context, then testing for the value of the Group using an IF or SWITCH statement.

 

So something like the following should work:

 

SUMX( table1 , 
SWITCH( table1[Groups (groups)]
  , "Haulage Trucks", table1[Work Hours in MN] + table1[Stop Hours in MN] 
  , "Key Accounts Trucks",  table1[Idling Hours in MN] + table1[Work Hours in MN] 
  )
)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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