Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
mendoncart
Contributor III
Contributor III

Getfieldselection Date Value

Hi guys.

I'm trying to get the selection of a filter with an auto calendar field: [DocDate.autoCalendar.YearMonth]

The thing is, if I use GetFieldSelections([DocDate.autoCalendar.YearMonth]), it appears to return a text value, and not a date one.

I need to get a date value to use the selected date into expressions, but I'm not being able to even convert the result in a MM/DD/YYYY type of date.

Can you guys help me how to get the date selected on the field, resulting a date value type?

Thanks in advance!

1 Solution

Accepted Solutions
mendoncart
Contributor III
Contributor III
Author

I've made it!

Thank you Sunny Talwar for your help and attention!

For whom may be interest to the solution, is just use date#(GetFieldSelections(YourDateField), 'YourDateFieldFormat').

In my case, I get the result 2016-Dec off GetFieldSelections, so this solves it:

date#(GetFieldSelections([DocDate.autoCalendar.YearMonth]),'YYYY-MMM')

View solution in original post

7 Replies
sunny_talwar

How exactly are you looking to use this? Are you hoping to select multiple YearMonths at a time or just a single value? If it is single, then you can use Only([DocDate.autoCalendar.YearMonth])

mendoncart
Contributor III
Contributor III
Author

This kinda works. But the thing is, I'm using this in a pivot table, and some of the values of the dimension doesn't have this field, or have a different value. So I need this selection value to use and compare with others value that I get.

And yes, I'll be selecting only one value.

sunny_talwar

Can you share an example of what you are doing?

mendoncart
Contributor III
Contributor III
Author

I'm comparing how much time since the last customer purchase.

So, I have a pivot table with some data, including the last purchase date.

But I'm having a problem:

     Since I'm using {1} in set analysis in the expression of the last purchase date, some times I get a date after the selected period. Lets say I've selected 2016-Dec, I want the last purchase date to be at the period selected or before it. So I need the month end of the selected period (12/31/2016) to use in set analysis as a limiter.

sunny_talwar

I guess you don't want to use {1} or may be use one, but allow for dates to be changed... but I am not entirely sure what fields you have and what exactly are you desiring to see. Would you be able to share a sample qvf?

mendoncart
Contributor III
Contributor III
Author

I've made it!

Thank you Sunny Talwar for your help and attention!

For whom may be interest to the solution, is just use date#(GetFieldSelections(YourDateField), 'YourDateFieldFormat').

In my case, I get the result 2016-Dec off GetFieldSelections, so this solves it:

date#(GetFieldSelections([DocDate.autoCalendar.YearMonth]),'YYYY-MMM')

Anil_Babu_Samineni

May be this?

If(GetFieldSelections([DocDate.autoCalendar.YearMonth]) > 0, Sum({<[DocDate.autoCalendar.YearMonth] = {'$(=MonthEnd(GetFieldSelections([DocDate.autoCalendar.YearMonth])))'}>}Sales),'NA')

Or it may issue with Format, First you can convert into Month and then Try same

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)