Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
azimabadi
Creator III
Creator III

Variable as a Field in Table

Hi everybody,

i have a table like this:

LineNr

myVar

1Sum( {<Tbl1.Field_1={"10"}>} Value )
2Sum( {<Tbl1.Field_1={"75"}>} Value )
3Sum( {<Tbl1.Field_1={"130"}>} Value )

now i need to have a Table Diagramm and calculate the value of field "myVar" in my table as a cilumn.

I have tried expressions like $(myVar) , $($(myVar)) , $($(=Only(myVar)) , ..... but none of them calculate the experssion!

Anybody has an idea?

Many Thanks - Peyman

1 Solution

Accepted Solutions
simondachstr
Luminary Alumni
Luminary Alumni

This should work as an expression:

Pick(Match(myVar,$(=Chr(39)& Concat(myVar, Chr(39)&','&Chr(39),LineNr) & Chr(39))),$(=Concat(myVar,',',LineNr)))

View solution in original post

5 Replies
simondachstr
Luminary Alumni
Luminary Alumni

What is the dimension? If your table is a data island, chances are that when you use myVar in a chart (table diagram) a Cartesian product is created: Every field will associate with every variable/formula. This means that the expression has no idea which field in myVar to evaluate thus returning null.

If you are trying to create a table with KPI, try working with ValueList() or ValueLoop() instead.

azimabadi
Creator III
Creator III
Author

Hi Martin,

the LineNr is my Dim. and i have considerd the point you hav mentioned in my set analysis.

My Problem is to calculate the content of a filed as an experssion in my table diagramm.

Best Regards - Peyman

simondachstr
Luminary Alumni
Luminary Alumni

This should work as an expression:

Pick(Match(myVar,$(=Chr(39)& Concat(myVar, Chr(39)&','&Chr(39),LineNr) & Chr(39))),$(=Concat(myVar,',',LineNr)))

azimabadi
Creator III
Creator III
Author

Hi Martin,

it's really berliant! I have to test this tomorrow.

I think that this will work.

the only problem is performace, becuse my table is relativ big and vars are long. I'm not sure how long can be the strings in QV.

Best Regards - Peyman

simondachstr
Luminary Alumni
Luminary Alumni


I think performance should be fine because the concat() function is calculated only once for the table. All that ofc as long as your expressions are straightforward themselves.