Forum Discussion
Dax Addition incorrect
- Anonymous4 years ago
Hi DonPepe ,
Firstly, create a flag measure to filter the table:
Flag = IF(MAX('CurrentWeek'[Activity Name])="Rust" && MAX('CurrentWeek'[RustBoni]) = "Y" ,1,0)OSPDur = CALCULATE(SUM(CurrentWeek[PLA Duration (seconds)]) /3600,FILTER(ALL(CurrentWeek), [Activity Name]<>"Rust"))Boni = [OSPDur]*0.6/7Output is the same as your Test table returns:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi ,
Thanks for your time.
I found the error and I have a granularity issue.
So I have one ID who make several task with a certain durantion during his day and my measure should represent :
If when 'CurrentWeek'[Activity Name]="Rust", 'CurrentWeek'[Boni] = "Y" then [OSPDur]+[Boni] --the measure else [OSPDur] -- the measure
But I dont know how to translate it in DAX.
here a sample of my data :
| ID | Activity Name | PLA Duration (seconds) | RustBoni |
| CLD334 | Te voet ingang >< bureau | 12 | N |
| CLD334 | Laden | 6 | N |
| CLD334 | Laden | 1119 | Y |
| CLD334 | Traject Parking >< Kade - camion fix | 93 | N |
| CLD334 | Afleveren voertuig | 310 | N |
| CLD334 | Te voet Kantoor >< Voertuig | 185 | N |
| CLD334 | Sleutels, documenten en scanner teruggeven | 310 | N |
| CLD334 | Rust | 2700 | Y |
| CLD334 | Lossen | 1269 | N |
| CLD334 | Te voet Kantoor >< Voertuig | 180 | N |
| CLD334 | Sleutels, documenten en scanner teruggeven | 300 | N |
| CLD334 | Te voet ingang >< bureau | 0 | N |
Thanks a lot,
Don
Ok I found a way with a new calculated table. I would have prefered with a measure but I dont master DAX enough.
Here the code of the new table :
Test =
SUMMARIZECOLUMNS(
CurrentWeek[ID],
"BoniYN",
IF(
ISBLANK(
CALCULATE(
MAX(CurrentWeek[RustBoni]),
CurrentWeek[Activity Name]="Rijden"
)
),
MAX(CurrentWeek[RustBoni]),
CALCULATE(
MAX(CurrentWeek[RustBoni]),
CurrentWeek[Activity Name]="Rijden"
)
),
"OSPDur",
CALCULATE(
SUM(CurrentWeek[PLA Duration (seconds)])/3600,
CurrentWeek[Activity Name]<>"Rust"
),
"Boni",
((
CALCULATE(
SUM(CurrentWeek[PLA Duration (seconds)])/3600,
CurrentWeek[Activity Name]<>"Rust"
)
)*0.6)/(7)
)Don