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
yaman123
Post Partisan
Post Partisan

Sum values based on function

Hi all, 

 

I need some assistance in creating a measure which sums values based on distinct function. I have the below dataset.

 

I need to sum the total possible hours per function. So total from below dataset should be 34495 and not 62465. As you can see, there can be more than one function depending on absence type, but the total possible hours should only be counted once towards that function. 

 

FUNCTIONABSENCE_TYPEABSENCE_HOURSTOTAL_POSSIBLE_HOURS
AS112480
B 0320
C 01600
D 01664
EM1689644
ES6729644
F 03648
G 0480
H 01088
IC369163
IF1809163
IS2049163
J 03688
K 01600
L 01120
   62465
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@yaman123 , Try measure like

 

sumx(summarize(Table, Table[FUNCTION], Table[TOTAL_POSSIBLE_HOURS]), [TOTAL_POSSIBLE_HOURS])

 

or

 

 

sumx(values(Table[FUNCTION]), calculate(Max (Table[TOTAL_POSSIBLE_HOURS])))

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

View solution in original post

Jihwan_Kim
Super User
Super User

Hi, @yaman123 

Please check the below.

 

Picture5.png

 

 

Total Possible Hours =
SUMX (
VALUES ( Data[FUNCTION] ),
CALCULATE ( MAX ( Data[TOTAL_POSSIBLE_HOURS] ) )
)

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Linkedin: https://www.linkedin.com/in/jihwankim1975/


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi, @yaman123 

Please check the below.

 

Picture5.png

 

 

Total Possible Hours =
SUMX (
VALUES ( Data[FUNCTION] ),
CALCULATE ( MAX ( Data[TOTAL_POSSIBLE_HOURS] ) )
)

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Linkedin: https://www.linkedin.com/in/jihwankim1975/


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

amitchandak
Super User
Super User

@yaman123 , Try measure like

 

sumx(summarize(Table, Table[FUNCTION], Table[TOTAL_POSSIBLE_HOURS]), [TOTAL_POSSIBLE_HOURS])

 

or

 

 

sumx(values(Table[FUNCTION]), calculate(Max (Table[TOTAL_POSSIBLE_HOURS])))

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

Hi @amitchandak 

 

Sorry revisiting this again. The numbers i have do not match to what my dataset is. 

 

From May 2020 - Apr 2021, the total should be 452.080, but when i use the formula sumx(summarize(Table, Table[FUNCTION], Table[TOTAL_POSSIBLE_HOURS]), [TOTAL_POSSIBLE_HOURS]), the total i get is 422.304. 

 

The total possible hours column sums the hours if there is more than one line per month for that function but i only want to show the distinct value for that function per month. 

 

Is there any way to write this? 

Thanks! That seems to have worked 

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.