Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Duplicate problem with alt-statement

Hi
I have following script in expression.
=sum(if(alt([Billing Day],0)=0,([Order quantity_WMENG]*Net_Price/ExhRate,0))

For some reason this this formula sums everything twice and I can't see what is the problem. Would you have any ideas. The formula calculates properly without if(alt statement, but with that all results are multiplied with 2. There shouldn't be any duplicate rows in my data model; all these needed values are only once in my data model.
Many thanks already beforehand
Regards
Janne
1 Solution

Accepted Solutions
er_mohit
Master II
Master II

Try your expression with distinct function

sum(distinct if(alt([Billing Day],0)=0,([Order quantity_WMENG]*Net_Price/ExhRate,0)))

if problem doesn't solve then try this


sum(distinct if([Billing Day]=0,([Order quantity_WMENG]*Net_Price/ExhRate,0)))

hope it helps


View solution in original post

4 Replies
Not applicable
Author

try this

=if([Billing Day]=0,sum(Distinct  ([Order quantity_WMENG]*Net_Price) / ExhRate),0)

Not applicable
Author

That wouldn't work. The reason why I need to use "alt"-statement here is that I want to include onlu those rows into calculation where Billing day doesn't exist, so with the normal if formula I get nothing.

er_mohit
Master II
Master II

Try your expression with distinct function

sum(distinct if(alt([Billing Day],0)=0,([Order quantity_WMENG]*Net_Price/ExhRate,0)))

if problem doesn't solve then try this


sum(distinct if([Billing Day]=0,([Order quantity_WMENG]*Net_Price/ExhRate,0)))

hope it helps


Not applicable
Author

Great! the first one did work! Many thanks!

-Janne