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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamic dimension or how to calculate with rows

Hi,

i've got the following pivot table

Resort Sales (=sum(Sales_1_Day) .....

A 50 ...

B 30 ...

Total 80 ...

now I want to have an additional row with following

sum(if(Resort = 'A', Sales_1_Day)) / sum(if(Resort='B', Sales_1_Day)) -> 50 /30 = 1,667:

Resort Sales (=sum(Sales_1_Day) .....

A 50 ...

B 30 ...

Total 80 ...

A/B 1,67 ...

Maybe someone can help me,

thanx a lot...

meili

8 Replies
Not applicable
Author

I can't figure out any way to do it within pivot table. If its just a single row you can add a text box next to the pivot table and use this expression within text box, else you have handle this at script level. Might be some can suggest a better way to do it 🙂

~Sachin

johnw
Champion III
Champion III

You could pull it off by making a calculated dimension that includes all the values for Resort, 'Total' and 'A/B'. Then have the expression behave differently for 'Total' and 'A/B'. It's not a great solution, but it should work. I THINK I have an example somewhere if you need one. I'd just need to find it.

(Edit: Found it. Attached. It's even more complicated than I remembered. Hopefully someone else has a better solution.)

Not applicable
Author

hi,

thank you all for your help although i cant really figure out how to solve the problem.:-(

In the above attached file I added a third column called resort and a pivot table.

Resort sum(test)

XX 49

YY 124

Total 173

Now a fourth row would be nice where i get XX/YY (49:124=0,395), instead of sum(test).

And there's not only one column sum(test) there are about 20 columns sum(test1), sum(test2)......

Thank you both for your help,

meili

ps. how do i get a qlikview-file in here?

Not applicable
Author

Hi,

I had a similar requirement,

If the resort values 'XX' and 'YY' are fixed. Then you can reference them in the expression with some hardcoding.

Not applicable
Author

Forgot to attach file.

I added a dummy resort value to your inline table


Not applicable
Author

John,

I've been searching all day for an answer. It looks like your post can solve my problem.

http://community.qlik.com/forums/t/40535.aspx

But why do you say it's not a great solution?

Rich

johnw
Champion III
Champion III

Well, the main thing I don't like about it is that it uses a calculated dimension. In my experience, calculated dimensions really slow down the associated charts. This calculated dimension seems particularly ugly due to the use of concat() in a valuelist(), which might cause problems if there were a large number of Products (perhaps a thousand or more?). QlikView isn't supposed to have a limitation on the size of expressions (the concat will be expanded into the expression, then the results evaluated), but in practice, I vaguely remember problems occurring. Then the expression has to do the same sort of complexity, which will probably slow the chart down any further.

Fortunately, that objection can be solved by making REAL values for the dimension. The attached example does that.

Other than that, it's not too bad, though probably in many cases the additional expressions might be handled through the data model instead of complicated chart expressions, which would be my preference. However, looking at your spreadsheet from the other thread, that seems like it would be complicated at best, and probably less clear than just playing with the expression as in the attached example. So with the modification to use a real dimension instead of a calculated one, yeah, on the surface this looks like a reasonable way to solve your problem.

Not applicable
Author

John do me a favor and post your response (testAddValuesToTable.qvw) to my post.

http://community.qlik.com/forums/t/40535.aspx

I'd like to verify your response but I can do it here from this link.

By the way it's ugly. BUT it works and it was painful. I did it on a realtively easy one with just one dimension ... year.

Now I'm going to need to concatenate the Region and year, then Salesperson and year. then ...

Thanks for your help.