Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Get the field name of expression in Dimension

Hi every one , Good Morning !

Today I need help in finding the field name of the expression. I created a

1) Bar Chart with

2) Dimension :  a) Region

                       b) =if(Month1=2,'Feb',If(Month1=3,'Mar',if(Month1=4,'Apr',if(Month1=5,'May','Jun'))))     [ Label = Month ]

both the dimension is grouped together and named as Group1.

3) Expression : Sum(Sales)

To get the result : I used =if(GetCurrentField([Group1])='Region','A',if(GetCurrentField([Group1])='Month1','B','C'))

but i did the result B .

30 Replies
Anonymous
Not applicable
Author

Hi Sunny,

you can try with any data just keep month data in integer format as 1,2,3,4,5 etc in table or data set

and use the below formula in Dimension in chart: =if(Month1=2,'Feb',If(Month1=3,'Mar',if(Month1=4,'Apr',if(Month1=5,'May','Jun'))))  Give label as ABC

now i want a text box where I want either name as Month or ABC when I select any month.( in sort field name not the expression )

sunny_talwar

Sorry, but don't have time to create a sample.... may be someone else might be able to help.

Best,

Sunny

Anonymous
Not applicable
Author

Please find the attachment of sample table.

sunny_talwar

Please find attached.... My and another approach

Capture.PNG

My approach expression

=If(GetCurrentField([Group1]) = 'Region', 'A',

If(GetCurrentField([Group1]) = '=if(Month=2,''Feb'',If(Month=3,''Mar'',if(Month=4,''Apr'',''May'')))', 'B', 'C'))

Other approach expression

=If(GetCurrentField([Group2]) = 'Region', 'A',

If(GetCurrentField([Group2]) = 'MonthName', 'B', 'C'))

Where MonthName is created in script like this

LOAD *,

Month(Date#(Month, 'M')) as MonthName;

LOAD * INLINE [

    Month, ProductCategory, Region, Country, Amount

    1, Arts & Entertainment, North AMerica, USA, 1245

    2, Hardware, South America, Brazil, 456

    3, Home & Garden, South America, Brazil, 241

    1, Food, South Asia, Singapore, 1247

    2, Home & Garden, South Asia, China, 5462

    4, Office Supplies, Australia, Australia, 577

];

I thought Marcus was suggesting this.... Sorry about that...

Anonymous
Not applicable
Author

Hi Sunny,

The main trick was on script result.jpg

Thanks again ,

but the expression part didn't worked

sunny_talwar

You have the expression in front of you... have you checked the file? Is it still not working for you?

Anonymous
Not applicable
Author

Hi Sunny,

Please find the attachment of image and observe the text box.

I did not get the desired result.

Chart: Bar Chart

Dimension: Group1 ( Drill Down)

Expression: Sum(Amt)

Issue.jpg

sunny_talwar

So here is why it doesn't work...

Capture.PNG

Your actual if statement begins with Month = 1, but in your check you are doing Month = 2. For this to work, you need to have the exact same expression (with commas, spaces, upper and lower cases) of the text to match 100%. If even a single thing doesn't match the expression is not going to work.

Anyways, it seems like your issue is resolved now, so I would ask you to close this thread by marking the correct and any other helpful responses.

Qlik Community Tip: Marking Replies as Correct or Helpful

Best,

Sunny

Anonymous
Not applicable
Author

Ok Sunny,

I change the expressions as per your request but still, i am facing the issue.Not.jpg

sunny_talwar

For every single quote you see, replace it with 2 single quotes

Capture.PNG

And replace these two single quotes or double quote with a single quote

Capture.PNG

Leave the single quotes around A and C as is... not change there.