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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
JuMo
Creator
Creator

Using a string to get a measure name

Hello

 

I have a series of measure that have the following format

KPI_A.Monthly

KPI_A.Target

KPI_A.Accumulative

KPI_A.EOY

KPI_B.Monthly

KPI_B.Target

KPI_B.Accumulative

KPI_B.EOY

KPI_C.Monthly

… etc …

 

I also have a table with the root name of the measures

KPI_Key

KPI_A

KPI_B

KPI_C

 

1) 1st Method

If I inject this table inside a variable (KPI_Analyzed_Key), I can (with a drop-down selector) select a KPI_Analyzed_Key and then display all the associated measure using this expression:

[$(KPI_Analyzed_Key).Monthly]

And it works perfectly, I’ve got the monthly value for the selected KPI

 

2) 2nd Method

Using the same approach, I want to display all my measure in the same table… I would like to have something like that

 

KPI_Key              Monthly              Target   Accumulative    EOY
KPI_A                          
KPI_B                         
KPI_C                          

 

However, I cannot manage to get it …

I’ve tried to duplicate the same formula as previously:

[$(KPI _Key).Monthly]

but its not working.

Any clue ?

Labels (4)
1 Solution

Accepted Solutions
Kushal_Chawda

@JuMo  You are trying to evaluate multiple master measure for each value of KPI which is not possible as measure is evaluated once for each value. If you want to evaluate different measure for each dimension value you will need something like pick (match(

With KPI_key as dimension you can create below measures.

Monthly: //Measure 1
=pick(Match(KPI_key,'KPI_A','KPI_B','KPI_C'),
[KPI_A.Monthly],[KPI_B.Monthly],[KPI_C.Monthly])

Target: // Measure 2
=pick(Match(KPI_key,'KPI_A','KPI_B','KPI_C'),
[KPI_A.Target],[KPI_B.Target],[KPI_C.Target])

EOY: //Measure 3
=pick(Match(KPI_key,'KPI_A','KPI_B','KPI_C'),
[KPI_A.EOY],[KPI_B.EOY],[KPI_C.EOY])

View solution in original post

21 Replies
Qrishna
Master
Master

Hi - When you say 'Using the same approach,..' whats the approach, could you provide the expression/code for that so we cn repeat the same and check if that works for the second case too?

JuMo
Creator
Creator
Author

Well the variable apporach was simple:

- There is a variable called KPI_Analyzed_Key

- There is a variable input drop down populated by my table/column KPI_Key and the value is saved in the variable KPI_Analyzed_Key

- To display a measure according to the selected variable, I use the following expression

[$(KPI_Analyzed_Key).Monthly]

And surprisingly, it works

 

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi @JuMo 

variable always holds single value at the time. So if you expect it to expand to different values for each row of your table - it will not work. Instead you may want to consider using function like Only() or MaxString() to pickup the value from the dim. 

Something like: [$(=Only(KPI _Key)).Monthly]

I would then preview how this expands in expression editor

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
JuMo
Creator
Creator
Author

Thanks .... The dollar sign seams to give an incorrect result, he is my result

KPI_Key Only(KPI_Key) $(=Only(KPI_Key)) [$(=Only(KPI_Key)).Monthly]
KPI_A                    KPI_A             - -
KPI_B                   KPI_B - -
KPI_C   KPI_C - -
lennart_mo
Creator
Creator

Hi @JuMo,

Try using the GetObjectField() Function, it should return the KPI-Key from each row, if you write it as a $-Sign expression.

So using something like [$(=GetObjectField(0)).Monthly] might work.

Qrishna
Master
Master

whats your expected output?

something like this:

(1).PNG

JuMo
Creator
Creator
Author

Thanks for your help, however, it's not working:

[$(=GetObjectField(0)).Monthly] returns "-"

KPI_Key [$(=GetObjectField(0)).Monthly]
KPI_A -
KPI_B -
KPI_C; -

 

$(=GetObjectField(0)) returns a string with the KPI key

KPI_Key $(=GetObjectField(0))
KPI_A KPI_A
KPI_B KPI_B
KPI_C; KPI_C

 

GetObjectField(0) returns the name of the dimention

KPI_Key GetObjectField(0)
KPI_A KPI_Key
KPI_B KPI_Key
KPI_C; KPI_Key

 

JuMo
Creator
Creator
Author

Yes, exactly

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi @JuMo 

Can you create simple Ctrl + 00 app ( just create new app and hit CTRL + 00 on keyboard in load script). That will autogenerate script for testing. Use this data to replicate sample you are trying to do then post it here. 

With actual app will be much quicker than going back and forth.

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.