Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

madnanansari
New Contributor III

Set Analysis

I have the below function which calculate the number of days till yesterday for the selections made in the filter for Year and month.

If there are no selections; it gives the number of days till yesterday during this month. For example today is 19th of october then this function will give 18. (the first line).

Where there is a selection; let say year 2017; it will give the number of days during the year till yesterday. and viceversa. (second line).

We have upgraded our system from 3.1 to september 2017 (b/c of some bugs to cover). Now the below function is giving '0' for all selections. please help to rectify.

If(getselectedcount([Year])<1 and getselectedcount([Month Year])<1,

Count({$<[Date] = {"<=$(=Today()-1)"},[Year]=,[Month Year]=,[MonthID]= {"$(=((Year(Today()) -1)*12) + Num(Month(Today())))"}>} [Date])

,

Count({$<[Date] = {"<=$(=Today()-1)"}>} [Date])

)

Tags (1)
13 Replies
isorinrusu
Contributor III

Re: Set Analysis

Hi Mohammad,

Probably the Date field format has been messed up with the upgrade. What's the Date field format?

Regards,

Sorin.

madnanansari
New Contributor III

Re: Set Analysis

Date is collected from the QVD file by the following:

Floor(SOH_DATE) as [Date],

isorinrusu
Contributor III

Re: Set Analysis

Try to change it to Date(Floor(SOH_DATE) as Date.

The floor function delivers an integer (for example 41382).

Or maybe

Regards,

Sorin.

madnanansari
New Contributor III

Re: Set Analysis

i tried. it also bring '0'.

pradosh_thakur
Valued Contributor III

Re: Set Analysis

try this


If(getselectedcount([Year])<1 and getselectedcount([Month Year])<1, Today() - MonthStart(Today())-1,Today() - YearStart(Makedate(Year))-1)


regards

Pradosh

madnanansari
New Contributor III

Re: Set Analysis

this will not work in case if i select multiple years

pradosh_thakur
Valued Contributor III

Re: Set Analysis

use min(year) instead

If(getselectedcount([Year])<1 and getselectedcount([Month Year])<1, Today() - MonthStart(Today())-1,Today() - YearStart(Makedate(min(Year)))-1)


regards

Pradosh

madnanansari
New Contributor III

Re: Set Analysis

this will not work in case if i select month only instead of year

pradosh_thakur
Valued Contributor III

Re: Set Analysis

your expression was working for month selection too?

may be this

If(getselectedcount([Year])<1 and getselectedcount([Month Year])<1 or  count(p(Month))=1, Today() - MonthStart(Today())-1,Today() - YearStart(Makedate(min(Year)))-1)

Community Browser