Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

christina_muell
New Contributor

Variable as dimension

Hey there,

I want to see some of my variables in combination with other fields in one dimension for an table (as shown in the example)

Maybe somebody has an idea?

Thank you Tina

9 Replies
vishsaggi
Esteemed Contributor III

Re: Variable as dimension

May be this see attached.

Use a straight table here.

Like add dim: Value_field

Expr:

= IF( Value_field = 'profit',profit,

  IF( Value_field = 'Sales_margin', [sales margin], Sum(Value)))

christina_muell
New Contributor

Re: Variable as dimension

Hey

Thank you for your answer!

It works! But if I select now a other field like for example a region, the variables disappear. (see attached)

I dont know how to solve that problem!

vishsaggi
Esteemed Contributor III

Re: Variable as dimension

What is that you want to see when you click on the region? I mean you want to see the values 15 and 2 in your profit and Sales_margin or 0's for these values?

christina_muell
New Contributor

Re: Variable as dimension

No I wanna see the values, that only belong to the selected region.

So for Nord 6 for Sales Margin and 2,5 for profit!

Thank you

vishsaggi
Esteemed Contributor III

Re: Variable as dimension

Ok will look into it. If not may be stalwar1‌ can help on this.

Re: Variable as dimension

May be try this

= IF(Only({1}Value_field) = 'profit',profit,

  IF(Only({1}Value_field) = 'Sales_margin', [sales margin], Sum(Value)))

vishsaggi
Esteemed Contributor III

Re: Variable as dimension

Superb. Cant believe completely forgot about this Only().

christina_muell
New Contributor

Re: Variable as dimension

Thank you
The selecting of the regions is now working!

So one more question: If I have two different years now in my data and I wanna show only one year in one of the table columns, how can I manage to do this? Because if I put an set analaysis or an "and" in the if-function it of course only shows me 0.

For the sum-function in the end, it works of course with a simple set analysis.

= IF(Only({1}Value_field) = 'profit',profit,

  IF(Only({1}Value_field) = 'Sales_margin', [sales margin], Sum({<Year={'2017'}>}Value)))

Re: Variable as dimension

Where exactly do you see 0? Can you elaborate?

Capture.PNG

Community Browser