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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
AndreDeLuca
Frequent Visitor

Calculated column to show Sum of values by month and by id

What i need is to create a conditional column that indicates if a person is over, under or full allocated for the month. For that condition we have two fields, "hoursPlanned" and "hoursExecuted". So what i thought was to create a SWITCH that would be something like this: 

SWITCH(TRUE(),
 f_Horas[hoursPlanned] = f_Horas[hoursExecuted], "Full",
 f_Horas[hoursPlanned] < f_Horas[hoursExecuted], "Over",
 f_Horas[hoursPlanned] > f_Horas[hoursExecuted], "Under")
 
This works, but in row context. I need it to be on person/month context, so i can analyse the situation for any person in any specific month. Since we have multiple lines for the same person on the same month,  i need to change the "f_Horas[hoursPlanned]" and "f_Horas[hoursExecuted]"  fields for a formula that calculates the total amount of hours per person and per month, and i don't know and couldn't find how to do that, so if anyone happens to have the solution i'll be very grateful. 
Thanks for the attention, any questions i'll be happy to answer.
1 ACCEPTED SOLUTION
AndreDeLuca
Frequent Visitor

I manage to create a formula that worked, here it is:

FULL/OVER/UNDER =

var p = CALCULATE(SUM(f_Horas[HorasPlanejadas]), ALLEXCEPT(f_Horas, f_Horas[Colaborador], f_Horas[MesAno]))

var r = CALCULATE(SUM(f_Horas[HorasRealizadas]), ALLEXCEPT(f_Horas, f_Horas[Colaborador], f_Horas[MesAno]))

var res =SWITCH(TRUE(),
 p = r, "Full",
 p < r, "Over",
 p > r, "Under")

return res  
 
Hope someone can benefit!

View solution in original post

1 REPLY 1
AndreDeLuca
Frequent Visitor

I manage to create a formula that worked, here it is:

FULL/OVER/UNDER =

var p = CALCULATE(SUM(f_Horas[HorasPlanejadas]), ALLEXCEPT(f_Horas, f_Horas[Colaborador], f_Horas[MesAno]))

var r = CALCULATE(SUM(f_Horas[HorasRealizadas]), ALLEXCEPT(f_Horas, f_Horas[Colaborador], f_Horas[MesAno]))

var res =SWITCH(TRUE(),
 p = r, "Full",
 p < r, "Over",
 p > r, "Under")

return res  
 
Hope someone can benefit!

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.