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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DonPepe
Helper II
Helper II

Dax Addition incorrect

Hi,

 

Do you know what is the cause of my false addition ? 35,00+3,00 is 38,00 not 38,75 or 38,21 or...

See below : in HperOSP, I add OSPDur to Boni If I have a Y in the table. here the measure :

 

HperOSP = 
var _SumBoni =
    CALCULATE (
        ( [OSPDur]+([Boni]) ),
        CurrentWeek[RustBoni] = "Y"
    )
var _SumNoBoni =
    CALCULATE (
        [OSPDur],
        CurrentWeek[RustBoni] = "N"
    )
return
    _SumBoni + _SumNoBoni

 

the result : (when "OSPDur = 35,00"  CurrentWeek[RustBoni] = "Y")

DonPepe_0-1649319015494.png

Thanks a lot for your help,

 

Don 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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/7

Output is the same as your Test table returns:

Eyelyn9_0-1649731648446.png

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.

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

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/7

Output is the same as your Test table returns:

Eyelyn9_0-1649731648446.png

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.

DonPepe
Helper II
Helper II

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 NamePLA Duration (seconds)RustBoni
CLD334Te voet ingang >< bureau12N
CLD334Laden6N
CLD334Laden1119Y
CLD334Traject Parking >< Kade - camion fix93N
CLD334Afleveren voertuig310N
CLD334Te voet Kantoor >< Voertuig185N
CLD334Sleutels, documenten en scanner teruggeven310N
CLD334Rust2700Y
CLD334Lossen1269N
CLD334Te voet Kantoor >< Voertuig180N
CLD334Sleutels, documenten en scanner teruggeven300N
CLD334Te voet ingang >< bureau0N

 

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

@DonPepe  Try this DAX:

= IF(CurrentWeek'[Activity Name]="Rust" && 'CurrentWeek'[Boni] = "Y" ,[OSPDur]+[Boni] ,[OSPDur])

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

@Tahreem24,

 

It worked in a calculated column but not in a measure. 

 

How can I put the condition on the line "Rust" and sum on all the ID ? 

 

Thanks,

 

Don

@DonPepe  You can use aggregate functions like MIN ,MAX etc.

= IF(MAX(CurrentWeek'[Activity Name])="Rust" && MAX('CurrentWeek'[Boni]) = "Y" ,[OSPDur]+[Boni] ,[OSPDur])

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Sorry but it didn't work. 
I think the issue comme from the granularity. 
I have to see on the task level if Rust ="Y" and if so, calculate on the ID level the sum of each task duration. 

OSPDur = Sum(CurrentWeek'[PLA Duration (seconds)])

and Boni = Sum(CurrentWeek'[PLA Duration (seconds)])*0.6/7


I don't know if you understand. But really thanks to help me. 

 

Don

Tahreem24
Super User
Super User

@DonPepe Can you share the sample data (by copy pasting or excel) here for better solving at my end?

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.