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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis, sum yesterday

So now I've got the below two separate working formulas, how do I put them together? My set analysis skills are poor, I never seem to learn the syntaxes

TODAYS

=SUM(IF(TYPE='XXX',AMOUNT))

BUT NEED TO USE YESTERDAYS DATE

IF(WeekDay(Max(Date)) = 'Mon', Date(Max(Date) - 3), Date(Max(Date) -1))

1 Solution

Accepted Solutions
PrashantSangle

Hi,

Try like

for today

sum({<Type={"XXX"},DateField={"=date(Today())"}>}Amount)

or

sum({<Type={"XXX"},DateField={"$(=date(max(datefield)))"}>}Amount)

for Yesterday

sum({<Type={"XXX"},DateField={"=date(Today()-1)"}>}Amount)

or

sum({<Type={"XXX"},DateField={"$(=date(max(datefield)-1))"}>}Amount)

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

9 Replies
mukesh24
Partner - Creator III
Partner - Creator III

Use Following syntax:-

sum( {$<Date= {$(#=Max(Date)-1)}>} Amount)

Regards,

Mukesh Chaudhari

Not applicable
Author

Hi Mukesh,

can you pls specify an example with my if condition (IF TYPE) as well?

Thanks in advance,

Olle

PrashantSangle

Hi,

Try like

for today

sum({<Type={"XXX"},DateField={"=date(Today())"}>}Amount)

or

sum({<Type={"XXX"},DateField={"$(=date(max(datefield)))"}>}Amount)

for Yesterday

sum({<Type={"XXX"},DateField={"=date(Today()-1)"}>}Amount)

or

sum({<Type={"XXX"},DateField={"$(=date(max(datefield)-1))"}>}Amount)

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

Hi Max,

I think I need to rephrase my request. I need to sum the previous date, meaning If current date is monday I need to show the sum of fridays amounts.

Hence my formula for this purpose:

IF(WeekDay(Max(Date)) = 'Mon', Date(Max(Date) - 3), Date(Max(Date) -1))

When trying your formula below Im getting only zero values.

sum({<Type={"XXX"},DateField={"$(=date(max(datefield)-1))"}>}Amount)

PrashantSangle

Hi,

Try like

if(weekday(Date)='Mon',

sum({<Type={"XXX"},DateField={"$(=date(max(datefield)-3))"}>}Amount),

sum({<Type={"XXX"},DateField={"$(=date(max(datefield)-1))"}>}Amount)

)

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

still getting zero values im afraid

PrashantSangle

Hi,

Debug your set analysis expression

1)convert your chart to straight table.

2)Write above expression.

3)dont write label

4)Press Ok

5) Once chart created , take your arrow to header of that expression.

Check what value it is showing for Datefield=

If possible post screen shot of it.

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Anonymous
Not applicable
Author

is it just a mistake in your statement, but on the left you write "Datefield" (upper D) and in the right expression you say

max(datefield) (lower d).

Instead of using if statement and test for monday you may use

firstworkdate(datefield,1) which delivers the previous workdate

and it works for public holidays as well (normally you will have no sales on a public holiday, except your shop is opened)

Not applicable
Author

Hi Rudolf,

that is a neat solutuion, however Im doing this for different currencies/countries with different holidays.

So I need something more dynamic

Kind REgards,

Olle