Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
sunny_talwar

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

Capture.PNG

View solution in original post

12 Replies
sunny_talwar

Try this

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

Anonymous
Not applicable
Author

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.

sunny_talwar

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

Anonymous
Not applicable
Author

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
Luminary Alumni
Luminary Alumni

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

Anonymous
Not applicable
Author

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.

sunny_talwar

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

Capture.PNG

Anonymous
Not applicable
Author

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)?

sunny_talwar

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)