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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Jacob11
Contributor
Contributor

Bouton variables & dates

Bonjour, 

Je cherche à créer un bouton qui définirait l'action d'une variable avec un travail sur les dates.
Il me faudrait une vision LTM (last twelve months) et une année calendaire. Grâce au bouton, mes données affichées passeraient donc d'une période à l'autre. 

J'ai essayé de travailler autour du champ Delivery_date mais j'ai du mal à rendre le résultat fiable, notamment côté LTM. Dans l'idéal, j'aimerais consolider le tout à l'aide d'un set analysis.

Savez-vous comment m'aider? 

Merci

1 Reply
Nagaraju_KCS
Specialist III
Specialist III

Try this

1. Create a variable vPeriod and you will configure two buttons

Button1: 'LTM' (set variable value as LTM)

Button2: 'CY' (set Variable value as 'CY'

2. LET vToday = Floor(Today()); 
    LET vThisYearStart = YearStart(Today());

3. Measure expression Current Year

Sum({<$(=If(vPeriodType = 'CY',
Delivery_date = {">=' & Date('$(vThisYearStart)') & '<=' & Date('$(vToday)') & '"}))>} YourMeasure)

4. Measure expression LTM

Sum({<
$(=If(vPeriodType = 'LTM',
Delivery_date = {">=' & Date(AddMonths('$(vToday)', -12)) & '<=' & Date('$(vToday)') & '"}))
>} YourMeasure)

5. if you want to switch with one measure CY and LTM

=Sum({<Delivery_date = {$(=If(vPeriodType = 'LTM',
'>=' & Date(AddMonths('$(vToday)', -12)) & '<=' & Date('$(vToday)'),

If(vPeriodType = 'CY',
'>=' & Date('$(vThisYearStart)') & '<=' & Date('$(vToday)'),
'$(=Only(Delivery_date))')))}>} YourMeasure)