Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to Combine 2 Expressions into One Expression

Hi Guys / QlikCommunity:

I have this Expression:-

=sum(if(transdate<CurrentDate -2,Qty))

And also this Expression:-

sum (if (invtype='20',goodqty)) - sum (if (invtype='34',goodqty))

+

sum (if (invtype='40',goodqty)) - sum (if (invtype='42',goodqty))

I need to combine both Expressions into one Expression.

I am not able to use Set Analysis for my Expression.

Could someone enlighten me how to do it?

Thanks a lot guys…

12 Replies
lironbaram
Partner - Master III
Partner - Master III

hei

can you explain a little bit more what you mean by combine the expression

what the resault you are after?

Not applicable
Author

Sorry guys:

Forget to add this:-

The Qty in the first Expression is equal to the second Expression which is

sum (if (invtype='20',goodqty)) - sum (if (invtype='34',goodqty))

+

sum (if (invtype='40',goodqty)) - sum (if (invtype='42',goodqty))

I need to combine both the Expression.

Thanks Guys

gandalfgray
Specialist II
Specialist II

How about:

sum(if(transdate<CurrentDate -2,

if (invtype='20',goodqty) - if (invtype='34',goodqty)

+

if (invtype='40',goodqty) - if (invtype='42',goodqty))

))


lironbaram
Partner - Master III
Partner - Master III

ok

lets give it a try

the first one is assuming currentDate is Varaible with the same value to all data

sum ({<invtype={20,40},transdate={"<$(=(#CurrentDate -2))"}>}goodqty)-

sum ({<invtype={34,42},transdate={"<$(=(#CurrentDate -2))"}>}goodqty)

the second for the case CurrentDate is a field with more then one value

sum ({<invtype={20,40}>}if(transdate<CurrentDate -2,goodqty))-

sum ({<invtype={34,42}>}if(transdate<CurrentDate -2,goodqty))

hope its helps you

Not applicable
Author

Hi GandalfGray and Guys:

Thanks you for your reply.

I try your Expression

sum(if(transdate<CurrentDate -2,

if (invtype='20',goodqty) - if (invtype='34',goodqty)

+

if (invtype='40',goodqty) - if (invtype='42',goodqty))

))

The result is Zero.

No sure what happen.

Hi liron baram:

I am not able to try your Expression because I am not able to use Set Analysis as I am using Qlikview 7.5.

There must be something wrong somewhere that I just can not pin point it…

Could anyone please help?

Thanks a lot

Anonymous
Not applicable
Author

not sure if this is wat you want.. but you can try this...

    if(transdate < (CurrentDate -2), sum(Qty),

    (if (invtype='20',sum(goodqty)) - if (invtype='34',sum(goodqty))) +

    (if (invtype='40',sum(goodqty)) - if (invtype='42',sum(goodqty)))

    )

hope this helps...

gandalfgray
Specialist II
Specialist II

Hi richardgan

I suggest you build the statement step by step and checks what part that makes you "lose" your expected data.

Starting with:

sum(if(transdate<CurrentDate -2, goodqty))

Make invtype a dimension and check what you get for all invtypes

If you get zero for all invtypes from that but are expecting something else you got to find why.

Not applicable
Author

Hi GandalfGray:

Thanks for your reply I will try just that.

Hi aadilmadarveet:

May i know where the Qty come from?

My First Expression:

=sum(if(transdate<CurrentDate -2,Qty))

The first Expression I have is that I need to change the Qty to the following Expression.

sum (if (invtype='20',goodqty)) - sum (if (invtype='34',goodqty))

+

sum (if (invtype='40',goodqty)) - sum (if (invtype='42',goodqty))

That is where I am trying to solve.

Thank you all for your kind help.

Anonymous
Not applicable
Author

Hi Richard,

I Think you can try this..

You can create a variable for CurrentDate -2 and then use it in the expression...

Sum({<transdate={"<$(DateVariable)"}>} (

(sum (if (invtype='20',goodqty)) - sum (if (invtype='34',goodqty)))

+

(sum (if (invtype='40',goodqty)) - sum (if (invtype='42',goodqty)))

))

hope i understand your question and providing some valuable solution..

thanks,

aadil