Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
April 13–15 - Dare to Unleash a New Professional You at Qlik Connect 2026: Register Now!
cancel
Showing results for 
Search instead for 
Did you mean: 
tuncfiratvb
Contributor
Contributor

GetFieldSelections

hi,

I have different reporting dates and to get difference between these two dates via GetFieldSelections formula used code below.

sum(If([Tarih.autoCalendar.Date]=GetFieldSelections(Tarih.autoCalendar.Date),[Total Balance Ecl]))-sum(If([Tarih.autoCalendar.Date]=GetObjectField(Tarih.autoCalendar.Date),[Total Balance Ecl]))

here the problem is I get difference as 0 but for the second one I wanna get the last selected date. How can I fix it ? Thanks in advance.

 

(I wanna get the difference of total balance ecl between two dates but it must be automatically thats why I used GetFieldSelections function)

8 Replies
Or
MVP
MVP

GetFieldSelections returns all of the selections on that field, which is more than one value...

Sounds like you might be looking for Min(Field) and Max(Field)?

tuncfiratvb
Contributor
Contributor
Author

actually there is two date which I added as filter to dashboard. I want the difference between first click and second click. Maybe "last" function should be used but I dont know how to do.

Or
MVP
MVP

I'm not sure what you mean by "Click".

If you have two separate fields, and each one has a single selected value, you can just use Field1 and Field2 without any functions. 

If this is a single field on which two selections have been made, getting the min and max selection should get you the first and last dates in the range.

tuncfiratvb
Contributor
Contributor
Author

actually by clicking I meant selection of the date or session but here I dont wanna write any specific date or session. thats why I used GetFieldSelections.  

tuncfiratvb_0-1634738575177.png

what I want from the formula is giving the difference between the first and second selection (I click on the 14/10/2021 firstly and later I click on the 08/10/2021). I am not sure if I explained correctly but thats the issue. Thanks by the way.

Or
MVP
MVP

I'm still not sure why you can't use min and max in this scenario. The smaller date selected will be the start of the range and the larger one will be the end of the range.

If for some reason you insist on doing it by the timing of the selection, you might be able to get at the specific selections made using $1 and $2 in set analysis (as explained in the set analysis documentation) but this won't work if you then make any other selection on any field and I think it may require you approve each selection individually, not sure about that one.

tuncfiratvb
Contributor
Contributor
Author

yes you are right actually ı have to use max-min functions. But How can use the max-min formula correctly here could please write it because I face with error when I try to write it down.

Or
MVP
MVP

date(min(Field)) and date(max(Field)) will probably work here. You may or may not need the date() part and you may need to format the date to match the existing formatting.

tuncfiratvb
Contributor
Contributor
Author

I tried this one but got an error in expression.

sum({$<date(max([Tarih.autoCalendar.Date]))>}[Total Balance Ecl])-sum({$<date(min([Tarih.autoCalendar.Date]))>}[Total Balance Ecl])

Community Browser