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: 
Not applicable

If expression current selection month < expression current selection month

Dear community,

I'm having troubles with creating a formula when a expression based of the current selected Month is greater then the same expression based of the current selected Month - 1 (previous Month), the object shows a green icon or a red icon.

The Icon with colors I can figure out, but Im stuck at the current month > previous month part.

This is what it approx. should look like, but cant seem to get the formula to work.

=If (Num((Sum({<Type={'A'}>}Project_Days_waiting)
/
Sum({<Type={'A'}>}Project_date_start)))
>
Num((Sum({<Type={'A'}>}Project_Days_waiting)
/
Sum({<Type={'A'}>}Project_date_start))) -previous month,'Green icon'
,'Red icon'))

Obviously the -previous month code part is wrong, but thats my question...what is the correct code in this situation.

Regards,

Sijmen

3 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Depends on what kind of month field you have.

Maybe

=If(Sum({<Type={'A'}>}Project_Days_waiting)/Sum({<Type={'A'}>}Project_date_start)

  >

  Sum({<Type={'A'}>}Project_Days_waiting)/Sum({<Type={'A'}>}Project_date_start)

  -

  Sum({<Type={'A'}, Month={'$(=max(Month)-1)'}>}Project_Days_waiting)/Sum({<Type={'A'}, Month={'$(=max(Month)-1)'}>}Project_date_start),

'Green icon',

'Red icon'

)


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks for the reply Gysbert.

We use 'Peil_datum' as the dimension where users can select a month in a listbox.

Listbox.png

So all I need to do is replace 'Month' with 'Peil_datum' in my situation?

Regards,

Sijmen

Not applicable
Author

Solved this by creating 2 variables in the document and using the 2 variables in the expression.

vSelectedYearMonth    Num(If( Max(Peil_Jaar_Maand) > Today(), Today(), Max(Peil_Jaar_Maand)))

vPrevSelectedYearMonth        num((VSelectedYearMonth)-1)

Use this part in the expression.

{< Peil_Jaar = {$(=Year(VPrevSelectedYearMonth))} , Peil_Maand = {$(=Month(VPrevSelectedYearMonth))}

Regards,

Sijmen