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

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

Reply
Anonymous
Not applicable

matrix with subtotals and calculation

Hello!

 

I have data that I want to have in Power BI in a visal like this - Stores by employees and then subtotals by Stores

Leiu_2-1728541042643.png

 

The data I have now is in a format like this

Leiu_3-1728541103567.png

I have managed to get the number of total shifts, Morning shifts and Evening Shifts (by using a custom column) but what I don't get is the % of morning/evening shifts (simple calculation morning shifts/total shifts)

I have tried it in Excel Power Query and Pivot as well as in Power BI with measures, calculated fields and all sorts of other ways but never arrived to the result..

 

Can please anyone help to guide me in the right direction?

 

1 ACCEPTED SOLUTION
Kedar_Pande
Super User
Super User

@Anonymous 

Create a calculated column:

Shift Type = 
IF(HOUR([Start of shift]) < 12, "Morning", "Evening")

Total Shifts Measure:

TotalShifts = COUNTROWS('YourTable')

Morning Shifts Measure:

MorningShifts = 
CALCULATE(
COUNTROWS('YourTable'),
'YourTable'[Shift Type] = "Morning"
)

Evening Shifts Measure

EveningShifts = 
CALCULATE(
COUNTROWS('YourTable'),
'YourTable'[Shift Type] = "Evening"
)

Morning Shift Percentage:

MorningShiftPercentage = 
DIVIDE([MorningShifts], [TotalShifts], 0) // Avoid divide by zero

Evening Shift Percentage

EveningShiftPercentage = 
DIVIDE([EveningShifts], [TotalShifts], 0) // Avoid divide by zero

If this helped, a Kudos 👍 or Solution mark would be great!🎉
Cheers,
Kedar Pande
Connect on LinkedIn

View solution in original post

2 REPLIES 2
Kedar_Pande
Super User
Super User

@Anonymous 

Create a calculated column:

Shift Type = 
IF(HOUR([Start of shift]) < 12, "Morning", "Evening")

Total Shifts Measure:

TotalShifts = COUNTROWS('YourTable')

Morning Shifts Measure:

MorningShifts = 
CALCULATE(
COUNTROWS('YourTable'),
'YourTable'[Shift Type] = "Morning"
)

Evening Shifts Measure

EveningShifts = 
CALCULATE(
COUNTROWS('YourTable'),
'YourTable'[Shift Type] = "Evening"
)

Morning Shift Percentage:

MorningShiftPercentage = 
DIVIDE([MorningShifts], [TotalShifts], 0) // Avoid divide by zero

Evening Shift Percentage

EveningShiftPercentage = 
DIVIDE([EveningShifts], [TotalShifts], 0) // Avoid divide by zero

If this helped, a Kudos 👍 or Solution mark would be great!🎉
Cheers,
Kedar Pande
Connect on LinkedIn

Anonymous
Not applicable

Super, thank you! this worked very well 🙂

 

Can you also maybe support if I want to add another measure/column that checks if the evening shifts % is below 25% or above 75% (in Excel it would be like this)

Leiu_0-1728553376233.png

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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
Top Kudoed Authors