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.
I have a bunch of engineers who get assigned work for each day and I have come up with a scoring system for how well each is utilissed on a particular day. What i woudl like the is overall average score for each day for all engineers, but getting something differnet that is an average of something, but can't work out what. Each engineer may have several calls assigned for one day so the score is based on their totla for the day.
Eng Day Score = VAR NewinHours=CALCULATE([Labour Hours],'Install Report'[CALL_TYPE]="NEWIN") RETURN AVERAGEX( SUMMARIZE( 'Install Report', DateTable[Day], 'Install Report'[ENGINEER] ), IF( [Newin Jobs]>2, 5, IF( [Newin Jobs]=2 || AND([Newin Jobs]=1,NewinHours>=7), 4, IF( [Newin Jobs]=1 && NewinHours<7 && [Labour Hours]>=6, 3, IF( [Labour Hours]>4, 2, 1 )))))
This is the result
So score for each engineer is right based on my if statement, but total should clearly be 2.5. I tried wrapping the measure in another AVERAGEX summarised jut by day but that makes no differnece. Any pointers appreciated?
Mike
Solved! Go to Solution.
Hi @masplin
You may create a condition measure.Then get the Eng Day Score with it.
Condition = VAR NewinHours = CALCULATE ( [Labour Hours], 'Install Report'[CALL_TYPE] = "NEWIN" ) RETURN IF ( [Newin Jobs] > 2, 5, IF ( [Newin Jobs] = 2 || AND ( [Newin Jobs] = 1, NewinHours >= 7 ), 4, IF ( [Newin Jobs] = 1 && NewinHours < 7 && [Labour Hours] >= 6, 3, IF ( [Labour Hours] > 4, 2, IF ( [Labour Hours] > 0, 1, 0 ) ) ) ) )
Eng Day Score = VAR NewinHours=CALCULATE([Labour Hours],'Install Report'[CALL_TYPE]="NEWIN") RETURN AVERAGEX( SUMMARIZE( 'Install Report', DateTable[Day], 'Install Report'[ENGINEER] ), [Condition] )
Regards,
To debug, I would try tp split it into 2 (or even 3) measures :
1) calculate the score
2) do an averagex over that.
sometimes this way it is easier to understand what is going on with contexts etc....
Proud to be a Super User!
Paul on Linkedin.
The whole point is to work out the calculation first for each enginner for each day and then secondly for all engineers per day so not sure how ALL(day) is going to help.
Here is a link to simplified pbix that just has 2 days in it Engineer Utilisation
To Pauls point I changed the calcuation to SUMX which I think is only way to break the measure (since calcuation has ot be done for all CALL_NUMBERS on that day for that engineer) and you can see that this is adding up all wrong in the total in the bottom table.
What is odd is some combinations of engineers on some days seem fine e.g. top table, but add in Adma and goes wrong.
Change the top table to 23rd and calculation goes wrong gain. Perflexed
Thnaks for any help
Mike
Hi @masplin
You may create a condition measure.Then get the Eng Day Score with it.
Condition = VAR NewinHours = CALCULATE ( [Labour Hours], 'Install Report'[CALL_TYPE] = "NEWIN" ) RETURN IF ( [Newin Jobs] > 2, 5, IF ( [Newin Jobs] = 2 || AND ( [Newin Jobs] = 1, NewinHours >= 7 ), 4, IF ( [Newin Jobs] = 1 && NewinHours < 7 && [Labour Hours] >= 6, 3, IF ( [Labour Hours] > 4, 2, IF ( [Labour Hours] > 0, 1, 0 ) ) ) ) )
Eng Day Score = VAR NewinHours=CALCULATE([Labour Hours],'Install Report'[CALL_TYPE]="NEWIN") RETURN AVERAGEX( SUMMARIZE( 'Install Report', DateTable[Day], 'Install Report'[ENGINEER] ), [Condition] )
Regards,
Seems if I put my VAR calaution inside the function it works. So a problem with my VAR clause maybe also needs to a SUMMARIZED version
SUMX( SUMMARIZE( 'Install Report', DateTable[Day], 'Install Report'[ENGINEER] ), IF( [Newin Jobs]>2, 5, IF( [Newin Jobs]=2 || AND([Newin Jobs]=1,CALCULATE([Labour Hours],'Install Report'[CALL_TYPE]="NEWIN")>=7), 4, IF( [Newin Jobs]=1 && CALCULATE([Labour Hours],'Install Report'[CALL_TYPE]="NEWIN")<7 && [Labour Hours]>=6, 3, IF( [Labour Hours]>4, 2, IF( [Labour Hours]>0, 1, 0 ))))))
That's great. So my question is why does this work and not my syntax?
Hi @masplin
It seems you may use ALL function: ALL(DateTable[Day]) to ignore the filters by date.Reference:https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept...
If you need further help,please share some sample data and expected output which would be helpful to provide an accurate solution.You can also upload the .pbix file to OneDrive and post the link here. Do mask sensitive data before uploading.
Regards,
Hi Cherie. As suggested have attached a sample file so any help on this apprecaited as same syntax seems to work fine on other calculations
Mike
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
100 | |
88 | |
68 | |
61 |
User | Count |
---|---|
150 | |
120 | |
100 | |
87 | |
68 |