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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
schuffe
Contributor III
Contributor III

Dont take the sum if Day is Saturday/Sunday

Hello everyone,

probably a very simple task but im not getting the right syntax.

So I have 2 columns 

Date | profit

01.01.2020 | 100

02.01.2020 | 80

... | ..

Now I want to sum only the profit of the Days (Monday to Friday). 

And i dont want to create a new column. I want to compute this in a formula.

My idea was like:

If(Weekday(Date)='Sa.' Or Weekday(Date)='So.',0,sum(profit))

 

That is not working. Maybe i have to do it with an 'Aggr' but i dont know exactly how to do it.

 

Thanks in advance . 🙂

 

1 Solution

Accepted Solutions
Or
MVP
MVP

Your if() needs to be inside your sum(), not vice versa. You need the if() statement evaluated for each row, but then you get a bunch of different sums with nothing to aggregate them.

sum(If(Weekday(Date)='Sa.' Or Weekday(Date)='So.',0,profit)

View solution in original post

2 Replies
Or
MVP
MVP

Your if() needs to be inside your sum(), not vice versa. You need the if() statement evaluated for each row, but then you get a bunch of different sums with nothing to aggregate them.

sum(If(Weekday(Date)='Sa.' Or Weekday(Date)='So.',0,profit)

schuffe
Contributor III
Contributor III
Author

Thanks 🙂 

It´s perfect