Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

vallolees
New Contributor II

GetFieldSelections with date dimension not returning value

Hi,

I'm trying to get the selected dates, but don't seem to GetFieldSelections function to return a value.

In my app the user can choose the data display period (year, quarter, month, day) via qsVariable extension. So I've created a master dimension like this: =Pick(Match($(vSalesView),1,2,3,4),[datestr.autoCalendar.Year],[datestr.autoCalendar.YearQuarter],[datestr.autoCalendar.YearMonth],[datestr.autoCalendar.Date]). This works fine.

So now I would like to display the selected dates in a text box and I wrote the following expression:

GetFieldSelections(Pick(Match($(vSalesView),1,2,3,4),[datestr.autoCalendar.Year],[datestr.autoCalendar.YearQuarter],[datestr.autoCalendar.YearMonth],[datestr.autoCalendar.Date]))

But this does not return any values when a selection is made

If I choose any other dimension, for example Customers, everything works fine. What am I doing wrong?

1 Solution

Accepted Solutions

Re: GetFieldSelections with date dimension not returning value

It seems that the use of Master Item might be causing this....

Capture.PNG

12 Replies

Re: GetFieldSelections with date dimension not returning value

Try this

GetFieldSelections($(=Pick(Match($(vSalesView),1,2,3,4),[datestr.autoCalendar.Year],[datestr.autoCalendar.YearQuarter],[datestr.autoCalendar.YearMonth],[datestr.autoCalendar.Date])))

vallolees
New Contributor II

Re: GetFieldSelections with date dimension not returning value

Thank you for the suggestion but unfortunately still nothing is returned.

I tried to wrap this expression inside isnull() and it returns true if one month is selected but when multiple months are selected the isnull() also doesn't return anything.

Re: GetFieldSelections with date dimension not returning value

Would you be able to share a sample to show the issue?

vallolees
New Contributor II

Re: GetFieldSelections with date dimension not returning value

Yes, please see the app attached below:

I don't know if this is an autoCalendar issue, but I also can't find the sum of selected periods sales. Although max and min dates are returned correctly.

juraj_misina
Valued Contributor

Re: GetFieldSelections with date dimension not returning value

Hi Vallo,

I'd try to rewrite it this way:

Pick($(vSalesView), GetFieldSelections([datestr.autoCalendar.Year]), GetFieldSelections([datestr.autoCalendar.YearQuarter]), GetFieldSelections([datestr.autoCalendar.YearMonth]), GetFieldSelections([datestr.autoCalendar.Date]))

PS: I'm pretty sure you can leave out Match() function since you are obviously comparing values 1, 2, 3, 4 to values 1, 2, 3, 4 so you can use the variable value itself as an input for Pick()

Hope this helps.

Juraj

vallolees
New Contributor II

Re: GetFieldSelections with date dimension not returning value

Hi Juraj,

Thanks for your input. You are right, I can leave out Match(), thanks. Unfortunately GetFieldSelections() still returns nothing. Please see the sample app where I have only [datestr.autoCalendar.YearMonth] month.

Re: GetFieldSelections with date dimension not returning value

It seems that the use of Master Item might be causing this....

Capture.PNG

vallolees
New Contributor II

Re: GetFieldSelections with date dimension not returning value

Thank You, this worked!

I guess as a workaround I'll write a Pick() function to every chart/table in my app as the dimension so I don't need to use the master item.

Any idea why it still isn't calculating sum of sales?

And is it possible to calculate the sum of sales based on the selected items alone (right now I'm calculating the sum between max and min value of date, but let's say the user selects Jan and March so it will show 400 as the sum)?

Re: GetFieldSelections with date dimension not returning value

When Jan and March are selected, you want to see 400? Try this

Sum(sales)

If you want 600, try this

Sum({$<[datestr.autoCalendar.YearMonth] = {"$(='>=' & MonthStart(Min([datestr.autoCalendar.YearMonth])) & '<=' &  MonthStart(Max([datestr.autoCalendar.YearMonth])))"}>} sales)

Community Browser