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: 
Zarnabkhan
Contributor
Contributor

Previous date by using variable in set expression

Hi All,

I'm trying to fetching  previous date data in measure by using set expression . My date in number format .

 

Code :

sum( {$<NUM_DATE=${('v_pre_date')}>} KNIT_BACKLOG_OPENGT )

//Date in number format

//variable value = today(date(NUM_DATE)) - 1

 

But my code is not working . Please help me .

Zarnabkhan_0-1592293985748.png

 

9 Replies
raji6763
Creator II
Creator II

hi @Zarnabkhan ,

You can calculate the previous date using these ways

  1. set analysis:

Sum({$<NUM_DATE={'$(Max(NUM_DATE)-1)'}>}KNIT_BACKLOG_OPENGT)

(or)

   2.Use variable

          a. Create variable : vPreviousDate = Max(NUM_DATE)-1

          b. Use set analysis : =Sum({$<[NUM_DATE]= {"$(=vPreviousDate)"}>} KNIT_BACKLOG_OPENGT)

regards,

raji

Zarnabkhan
Contributor
Contributor
Author

Thanks Raji , i tried ,   but your solution is not working .  With fix date working fine.

=sum( {$<[DATE.autoCalendar.Date]={"6/14/2020"}>} KNIT_BACKLOG_OPENGT )

above line with date format working fine but date in number format and using variable is not working . 

=Sum({$<[NUMDATE]= {"$(=vPreviousDate)"}>} KNIT_BACKLOG_OPENGT)

above code compiles but gives logical error. 

 

Please Help.

 

Regards:

Zarnab Khan

Anil_Babu_Samineni

how did you define the variable? Try this way

=Sum({$<[NUMDATE]= {"=$(=vPreviousDate)"}>} KNIT_BACKLOG_OPENGT)

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
tresesco
MVP
MVP

Your variable definition needs to be corrected I guess. Try like:

vPreviousDate = today() - 1

Zarnabkhan
Contributor
Contributor
Author

Thanks to all ,  your solutions compiles successfully but  giving no results. 

raji6763
Creator II
Creator II

could you please check your field name?please share your set expression and variable value

tresesco
MVP
MVP

Try to share your sample app. Also try like:

vPreviousDate = Date(today() - 1, 'M/D/YYYY')

=Sum({$<[NUMDATE]= {'$(=vPreviousDate)'}>} KNIT_BACKLOG_OPENGT)

Zarnabkhan
Contributor
Contributor
Author

Dear Tresesco  thanks for your reply , but   your expression giving error please check attached screen shorts .

tresesco
MVP
MVP

Put '=' sign in variable definition and try.