Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

GetFieldSelections does not work for dimensions

HI All,

When I use GetFieldSelections(MyDimension) it returns no results.

If I used it like GetFieldSelections([The_Expression_I_use_In_My_Dimension]) it works fine.

Is this behavior by design or I'm not using the right syntax.


For example: MyDimension: If(MyField = $(VMyVar), MyField, Null)

GetFieldSelections(MyDimension) - no results

GetFieldSelections([ If(MyField = $(VMyVar), MyField, Null)]) - works as expected.


Any input will be greatly appreciated.




Thanks

6 Replies
sunny_talwar

Not entirely sure what you are trying to do, but try dollar sign expansion may be

$(=GetFieldSelections(MyDimension))

Not applicable
Author

Hi,

Thanks for responding.

I need to identify a value selected in a calculated dimension.

The GetFieldSelections function only works if I put the expression instead of the dimension name.

I have lareday tried the suggested syntax, to no avail unfortunately.

In my case I need calculated dimensions as I use the filters from qsVariable input, but this is a different topic.


To reproduce the issue I'm asking about simply try to create a dimension that concatenates 2 fields and then use GetFieldSelections first with the same concatenation expression - that one would work and next with your dimension name, that one won't work.


I'm trying to understand the cause of this behavior - bug or feature and if there's a way around it.



Thanks

ahaahaaha
Partner - Master
Partner - Master

Hi Andrei,

Can we see a small fragment of your source data, for example in Excel and what do you want to get as a result on them?

Regards,

Andrey

Not applicable
Author

Hi Andrey,

Thank you for your response.

I created a simple app but I can't attach it.

The issue still can be reproduced, though.

In the loader create table Items as:

Items:

LOAD * INLINE

[OrderDate, Code, Quantity

'2017-03-01', 'ISBN0001', 3

'2017-03-01', 'ISBN0002', 5

'2017-03-01', 'ISBN0003', 9

'2017-03-02', 'ISBN0004', 1

'2017-03-02', 'ISBN0005', 2

'2017-03-02', 'ISBN0003', 1

'2017-03-02', 'ISBN0001', 1

'2017-03-03', 'ISBN0002', 1

'2017-03-03', 'ISBN0004', 3

'2017-03-05', 'ISBN0010', 5

'2017-03-05', 'ISBN0002', 1

'2017-03-06', 'ISBN0005', 1

]

;

Create a new sheet, name it Items Summary

Create new variables;

Variables:

Name: vCode Definition:  Code

Name: vOrderDateStart Definition:  OrderDate

Name: vOrderDateEnd Definition:  OrderDate

Create 2 variable objects called DateStart and DateEnd and associate them with the vOrderDateStart and vOrderDateEnd accordingly.

Create the following dimensions:

OrderDatesInRange:If(OrderDate >= '$(vOrderDateStart)' And OrderDate <= '$(vOrderDateEnd)', Date(OrderDate, 'DD/MM/YYYY'), Null)

CodesInRange: If(OrderDate >= '$(vOrderDateStart)' And OrderDate <= '$(vOrderDateEnd)', Code, Null)

CodesInRangeNotWorking: If(IsNull([OrderDatesInRange]) = True , Null, [Code])

SelectedItem: If(Code = GetFieldSelections([=If(OrderDate >= '$(vOrderDateStart)' And OrderDate <= '$(vOrderDateEnd)', Code, Null)]), Code, Null)

SelectedItemNotWorking: If(Code = GetFieldSelections([CodesInRange]), Code, Null)

If you  bring them to the sheet and enter the date range between 01/03 and 03/03 for example you will see that CodesInRange shows the codes associated with the entered dates while CodesInRangeNotWorking still lists all codes.

If you select 1 of the codes SelectedItem will show it but SelectedItemNotWorking will not.

The difference is that in the not working dimensions I refer to another dimension name, while in the working dimensions I use the full expression,

I hope this makes more sense.

If there's a way to attach the application, please could you let me know how to do so and I will attach it.

Thank you in advance for your help.

Andrei

ahaahaaha
Partner - Master
Partner - Master

Hi Andrei,

To attach a file

1.

1.jpg

2.

2.jpg

3. From From the folder "F:\Users\[Your UserName]\Qlik\Sense\Apps" add your file.

Regards,

Andrey

Not applicable
Author

Hi Andrey,

Many thanks for the instructions.

I attached my repro file.

It has 2 sheets - one with the issue in question and another with a workaround that was sufficient for me.

I added comments to each of the sheets, so hopefully it's clear enough what the issue is about and how to workaround it if needed.

The behavior of the GetFieldSelections function is interesting though - why won't it work if I use the calculated dimension's name.

Many thanks again, for your help!

Andrei