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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculate sum and distinctcount of wo DAX

Hi Guys, I am new to power bi and in need of a urgent help please. I have work order numbers(wonum) field and woassignedflag field and a jobduration field. now I want to calculate sum(Jobduration) for each distinct wonum where woassignedflag = 1

 

Can anybody help me on this please, this is very urgent for me. Thanks

7 REPLIES 7
Greg_Deckler
Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks Greg, I have looked at it and yes I didn't post sample data because I thought it is straight forward to understand, if you want I can post sample data if that speeds up solvation.Thanks for your reply.

Sample/example data always makes answers more accurate. Totally guessing without it. So, a total guess would be:

 

Measure = CALCULATE(SUM('Table'[Jobduration]),FILTER('Table',[woassignedflag]=1))

?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Anonymous
Not applicable

Hi

 

Greg solution works perfectly and giving the expected output. Are you still looking for something?

 

Capture_Sum.PNG

 

Thanks
Raj

Anonymous
Not applicable

Hi yes it did work for the scenario I asked, Thanks a lot for Greg for that.....but I missed to tell something important. As one work order will be assigned to multiple people the job duration for that workorder will the duplicated if I do sum(jobduration). For example if we have wo 1 job duration as 5 hrs. This wo is assigned to 3 Engineers (Enigeeneer 1, Engg 2, Engg 3). Each will have 5 hrs of job duration. So if I do sum(jobduration it gives me 15 hrs instead I want it to show 5 hrs as job duration is unique to workorder.
So my plan after struggling a lot today was to create a flag for unique WO..as posted the link requesting for possible way to achieve it. Can you please help me.. So tha sample data and the output I am looking for is below, I have already got woassigned flag created at the backend. I don't have running - count, Wo Uniquie Flag, and the calculation for sum(Job duration). PLEASE HELP

 

WonumJobDuraintwoassigned flagEngineerRunning-CountWo Uniquie Flag
123451Sandeep11
123451Greg20
123451Raj30
123451Kevin40
7896101Tom11
7896101Sam20
7654501Rahul11
7654500Sandeep10
      
Output     
Sum(Jobduration) for each distinct WO where woassigned =1wonum    
51234    
107896    
507654    
Anonymous
Not applicable

Hi Greg,

 

Thanks for your reply, I want to include distinctcount(Wonum) as well in the calculation since one workorder may be assigned to multiple people or one workorder may have different job durations. I have posted the sample data can you please check and let me know please

 

WoNumJobDurationWoAssignedFlagName SUM(JobDuration) for distinctcount of Wonum where assigned flag =1 when selected Sandeep in filterwonumJobDuration SUM(JobDuration) for distinctcount of Wonum where assigned flag =1 when selected Greg in filterwonumJobDuration
1300Sandeep  144  512 
1211Sandeep  210  788 
1231Sandeep  434  178 
2101Sandeep  523     
3300Sandeep         
4341Sandeep         
5231Sandeep         
5121Greg         
6340Greg         
1781Greg         
7120Greg         
7341Greg         
7541Greg         

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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