Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
rahulsingh12
Contributor III
Contributor III

Sum at 1st of every month

Hi,

 

I have daily sales data from 1st Jan 2020 to date. I want to create a table where I show the month and sum of sales such that if the month in the table is not equal to month(today()) then it should show sale of 1st of every month else the sale of the max date of the current month.

I wrote the below expression:

IF(TRENDDATEMONTH=MONTH(TODAY()),SUM({<TRENDDATE={"$(vMaxAutoDate)"}>}Final_Cumulative_Cases),

SUM({<TRENDDATE={"=$(=num(monthstart(MAX(TRENDDATE))))"}>}Final_Cumulative_Cases)

)

 

For the current month of March, it shows correct data for 22nd March 2020 but for other Months of Jan/Feb it is summing up the sales for all days for respective months. Is there a way I can fix the formula.

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

HI,

The best way is you create a flag in script to identify the month.

Considering today's date is 23rd Mar 2020.

So your flag expression should be.

If(TRENDDATE = today(),1,

If(TRENDDATE = Monthstart(TRENDDATE),1,0)) as Flag.

Now use this flag in your set analysis.

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

3 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

HI,

The best way is you create a flag in script to identify the month.

Considering today's date is 23rd Mar 2020.

So your flag expression should be.

If(TRENDDATE = today(),1,

If(TRENDDATE = Monthstart(TRENDDATE),1,0)) as Flag.

Now use this flag in your set analysis.

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
alex00321
Creator II
Creator II

You are right! I just expand and put in attached file.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Perfect.

Please mark the post as "Correct Answer"

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!