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

Conditional Sum

Hi

I need to make a conditional sum and I´m having many problems to get it. Need to sum the sales in 2018. This is thes expresion I´m using but doesn´t go on:

SUM({<[2018.FECHA EX] = {">31/12/2017"}>}[2018.BASE IMPONIBLE])

[2018.FECHA EX]  and [2018.BASE IMPONIBLE] are fields of the tables both of them.

I´ve read several posts about this but t I don´t get to resolve it.

 

Thanks.

 

Labels (3)
2 Solutions

Accepted Solutions
fjgonzalezcab
Contributor II
Contributor II
Author

The text box show 12/31/18

Qlik sense has stored directly the dates as MM/DD/YYYY, making this change the expression you told me go on!!

SUM({<[2018.FECHA EX] = {">$(=DATE#('01/01/2017','MM/DD/YYYY'))"}>}[2018.BASE IMPONIBLE])

Can you recommend me any post or articule that explain all this?

Thank you very much for your help.

 

View solution in original post

7 Replies
pradosh_thakur
Master II
Master II

May be this

 

SUM({<[2018.FECHA EX] = {">$(=DATE#(31/12/2017,'DD/MM/YYYY'))"}>}[2018.BASE IMPONIBLE])

Please make sure  [2018.FECHA EX] is a date and not a string.

 

Learning never stops.
fjgonzalezcab
Contributor II
Contributor II
Author

Thanks for your quick response.

That expresion doesn´t go on also. How can I make sure about the format of the field?

Thanks a lot for your help.
pradosh_thakur
Master II
Master II

Put max([2018.FECHA EX]) in a text box and show the output.

 

try the below  as well

SUM({<[2018.FECHA EX] = {">$(=DATE#('31/12/2017','DD/MM/YYYY'))"}>}[2018.BASE IMPONIBLE])

, you should not hard code the value though. 

Learning never stops.
vishsaggi
Champion III
Champion III

Is 31/12/2017 hardcoded value or you are planning to use a field name here. If it is hard coded i would suggest to use a variable then use this variable in your set. And make sure your 2018.FechaEx field format matching your static value. Check the format and change it as pradosh suggested.
fjgonzalezcab
Contributor II
Contributor II
Author

The text box show 12/31/18

Qlik sense has stored directly the dates as MM/DD/YYYY, making this change the expression you told me go on!!

SUM({<[2018.FECHA EX] = {">$(=DATE#('01/01/2017','MM/DD/YYYY'))"}>}[2018.BASE IMPONIBLE])

Can you recommend me any post or articule that explain all this?

Thank you very much for your help.

 

fjgonzalezcab
Contributor II
Contributor II
Author

Of course. thanks a lot for your help.