Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

sum of columns instead of sum of rows

Sorry, I can't explain better. I have a table like this:
-------------------- Sales ---------------------

Sales DE | 100 | 110 |

Sales UK | 80 | 40 |

Sales IT | 200 | 220 |

Total | 380 | 270 |


I'd like to have a table like this

-------------------- Sales ---------------------

Sales DE 210 | 100 | 110 |

Sales UK 120 | 80 | 40 |

Sales IT 420 | 200 | 220 |


anyone can help me? Thanks

21 Replies
Not applicable
Author

In your load script do something like this:

LOAD

fielda,

fieldb,

fielda+fieldb as fieldsum

FROM.................etc etc

Not applicable
Author

Thanks, but it is not possibile: the number I've to sum are a result of a complex "post-load" (



if( Tag_Stato='ACC',if(GetFieldSelections(Tag_BS,'')='MWh',sum(MAcc*if( Tag_BS='BID',-1,1 )),avg(EMAcc*if( Tag_BS='BID',-1,1 ))),0 )



); that is, it is not so easy to pre-calculate the sum, and it depends constantly on the selections made by the user selections!

Am I clear?

i don't know if it is possibile to do what I want.

Not applicable
Author

How about post your load script and any post load details so we can understand your problem

Not applicable
Author

the load is simple, I cannot paste the exatly what I implemented, but it sounds like this:

select A, B, C from c:\...\name.qvd

and it can't be modified because It could costs bad performance during load action.

after load, I created a pivot table with an expression similar to the one I wrote before, and dimensions like Time and Zone...

I wonder, if it is so easy to make the pivot table summing "Horizontally" the results of an expression, wouldn't that be easy to do the same thing "Vertically"

Not applicable
Author

Column(1) +Column(2) just do it, I hope it´s ok

Not applicable
Author

me too... but it does'nt work, if I try to make a calculated dimension like

SUM ( if(tag_stato='ACC', if(Get....))),0 ) there is an "Error in Expression"...

Not applicable
Author

I think you'll find that what Rose2 (I think that it anyway) was suggesting is a little bit different to what you have done.

Let's say you have the following in a table:

One Dimension

First Expression - very complex formula that's working well, and you have called it Value1

Second Expression - another very complex formula that's also working well, and you have called this Value2

Third expression - you want a sum of the above two.....

Simply create an expression like =[Value1] + [Value2] i.e. you can refer to the names of expressions in the expression of another, what Rose2 was suggesting is also correct in that you can refer directly to column numbers, in this case because you have one dimension then your first expression is column 2 so you could create an expression like =[Column1] + [Column2]

Hope this helps.

Nigel.

Not applicable
Author

Nigel's reply will give you what you are looking for. To help clarify...

In your list of Expressionis let's say you currently have

Label Definition

Expr1 If(Tag_Stats='ACC'.....

Expr2 If( {some other complex expression}

You can add another expression that references the labels you have put on the other two expressions. For Example:

Total =[Expr1]+[Expr2]

You can promote/demote this expression to appear either first or last in the list of expressions. If I understand your question correctly, this will solve your problem.

Regards,

sjprows

Not applicable
Author

I thank you all, I appreciate very much your suggestions. I will try your solution soon.

I'm sorry about not having been immediately accurate, I didn't think it could be useful. Let's give you another "trick" (after that I think there'll be nothing more to specify about my problem).

The column are not 2, but 24 (hours), because the table represents a Market Trend. Do I have to sum 24 elements (that is, [Expr where hour=1]+[Expr where hour=2]+[Expr where hour=2]...+[Expr where hour=24], having the "where" condition implemented with the appropriate set analysis function?

I hope to be right.

Thank you again