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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Column sum issue

Hi Community,

I need a small & quick help, its probably something too simple 😊

My matrix on the report looks like following: I have a calender table that is linked to my data table

 

Capture_2032.PNG

Leaves in hrs is calculated from two columns 'Start_date' & end_date' which are the dates of leaves taken. I converted the number of leaves take(in days) to Hours.

Hrs_worked = hrs_per_month - Leaves in Hrs

Hrs_worked is a column. The issue is I can't get the Hrs_worked right where there is more than one 'Leaves in hrs' (hrs worked in blue are expected hours_worked).

Please suggest how can I get the right Hours_worked.

My pbi:  https://1drv.ms/u/s!Ag919_pO_UKrgRJuluqNoYvl-Zba?e=NynFhy

TIA

 

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

Hi @Anonymous ,

You'd better create measure instead of calculated column to calculate the Hours worked. Try the following formula.

Measure = 
MAX(HASI_Wrkhrs[Hrs per month]) - CALCULATE(
    SUM(HASI_Wrkhrs[Leaves in hrs]),
    FILTER(
        ALLSELECTED(HASI_Wrkhrs),
        HASI_Wrkhrs[emp_code] = MAX(HASI_Wrkhrs[emp_code])
        && MONTH(HASI_Wrkhrs[date_start]) = MONTH( MAX(HASI_Wrkhrs[date_start]) )
        && HASI_Wrkhrs[date_start] <= MAX(HASI_Wrkhrs[date_start])
    )
)

v-kkf-msft_2-1614754211136.jpeg

v-kkf-msft_1-1614754154853.jpeg

This is my PBIX file.

https://microsoftapc-my.sharepoint.com/:u:/g/personal/v-lazhang_microsoft_com/ER1eRizE3zZDio7gkAaxWx4B9NHvgasQrsMZXKbB9BHymQ?e=UnNLry


If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

You'd better create measure instead of calculated column to calculate the Hours worked. Try the following formula.

Measure = 
MAX(HASI_Wrkhrs[Hrs per month]) - CALCULATE(
    SUM(HASI_Wrkhrs[Leaves in hrs]),
    FILTER(
        ALLSELECTED(HASI_Wrkhrs),
        HASI_Wrkhrs[emp_code] = MAX(HASI_Wrkhrs[emp_code])
        && MONTH(HASI_Wrkhrs[date_start]) = MONTH( MAX(HASI_Wrkhrs[date_start]) )
        && HASI_Wrkhrs[date_start] <= MAX(HASI_Wrkhrs[date_start])
    )
)

v-kkf-msft_2-1614754211136.jpeg

v-kkf-msft_1-1614754154853.jpeg

This is my PBIX file.

https://microsoftapc-my.sharepoint.com/:u:/g/personal/v-lazhang_microsoft_com/ER1eRizE3zZDio7gkAaxWx4B9NHvgasQrsMZXKbB9BHymQ?e=UnNLry


If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

FarhanAhmed
Community Champion
Community Champion

Can you please share some data also can you please share how are you calculating Leave Hrs & Hrs Worked with your data?







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

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

@FarhanAhmed  & @amitchandak  I have updated my post with Pbi file link.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.