Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Iras
Contributor III
Contributor III

how to subtract a month inside the set analysis

Dear all, 

I am trying to write a measure for this particular case for one of my KPI i.e. 

sum({<ReportMonth={$(=addmonths(MAX(ReportMonth),-1))}>}[sales])/100 

wherein I want to sum the sales for last month.. 

here Reporting month is in data format dd.mm.yyyy. 

but this is not working could some one please help me out for this issue ? 

 

I am geeting this as error :Error in set modifier ad hoc element list: ',' or ')' expected

 

Regards 

Iras

 

Labels (2)
2 Solutions

Accepted Solutions
Anil_Babu_Samineni

Perhaps this

sum({<ReportMonth={"$(=Date(AddMonths(Max(ReportMonth),-1),'DD.MM.YYYY'))"}>} sales)/100 

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

Iras
Contributor III
Contributor III
Author

Dear Mr. Anil babu, 

 

Thanks for your reply but it didn't work out. I found other soultion for it. 

sum({<ReportMonth={$(=num(addmonths(MAX(ReportMonth),-1)))}>}[sales])/100

The problem was It has to convert to num rather than date. 

View solution in original post

3 Replies
Taoufiq_Zarra

Maye be

you can create variable MaxDate as :

=Date(Max(Date#(ReportMonth,'DD.MM.YYYY')))

 

then your formula :

=Sum({<ReportMonth = {"$(=Date(addmonths('$(MaxDate)',-1),'DD.MM.YYYY'))"}>} [sales])/100

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Anil_Babu_Samineni

Perhaps this

sum({<ReportMonth={"$(=Date(AddMonths(Max(ReportMonth),-1),'DD.MM.YYYY'))"}>} sales)/100 

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Iras
Contributor III
Contributor III
Author

Dear Mr. Anil babu, 

 

Thanks for your reply but it didn't work out. I found other soultion for it. 

sum({<ReportMonth={$(=num(addmonths(MAX(ReportMonth),-1)))}>}[sales])/100

The problem was It has to convert to num rather than date.