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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Combining Dimension Values in a Single Pivot Cell

Hi,

I need to to combine two values in a single pivot cell to show the following :

AprMayJunJulAugSep
Incomes4 (7)8711 (11)52 (4)

The data that supplies this pivot would be set out in the following way :

IncomeApr4
Income_2Apr7
IncomeMay8
IncomeJun7
IncomeJul11
Income_2Jul11
Income Aug5
IncomeSep2
Income_2Sep4

So What I basically need to test for is if there is an Income_2 for a month then show it in Brackets in the same cell for the same month.

Many thanks for any help!!

Tom

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

Please find attached. If your data model is a little different, then you might have to change up the expression. Used ='Incomes' as a dimension along with Month. Then for the expression I used:

if(count(Income)=1, Income, concat(Income, ' (') & ')')

Hope this helps!

View solution in original post

16 Replies
jerem1234
Specialist II
Specialist II

Please find attached. If your data model is a little different, then you might have to change up the expression. Used ='Incomes' as a dimension along with Month. Then for the expression I used:

if(count(Income)=1, Income, concat(Income, ' (') & ')')

Hope this helps!

Not applicable
Author

Excellent - many thanks for your help!

Not applicable
Author

Hope you dont mind me asking another question?  If, more indicators are added to the data in future is it possibly to amend the expression based on an Indicator_ID ? eg :

Ind_NoIndicatorMonthNumber
1IncomeApr4
2Income_2Apr7
1IncomeMay8
1IncomeJun7
1IncomeJul11
2Income_2Jul11
1IncomeAug5
1IncomeSep2
2Income_2Sep4
3SalesApr45
3SalesMay32
3SalesJun22
3SalesJul56
3SalesAug24
3SalesSep65

to show

IndicatorAprMayJunJulAugSep
Income4 (7)8711 (11)52 (4)
Sales453222562465
Grand Total564029782971

Many thanks again for  your help!

Tom

jerem1234
Specialist II
Specialist II

Added the extra requirements, please find attached.

Hope this helps!

Not applicable
Author

Outstanding - much appreciated!

Tom

Not applicable
Author

Hi again,

This solution was working perfectly until the requirement was changed.  The source data now has many more indicators, so rather then combine values for Indicators 1 and 2, I have added a concat_flag field to the data.

I've attached a sample doc based on your original solution with test data loaded and an example of what I need to show.

Many thanks for your time.

Regards,

Tom

jerem1234
Specialist II
Specialist II

Please find attached.

Hope this helps!

Not applicable
Author

HI,

Thanks again for your help - works perfectly. 

I'm now trying to include this solution in some other dashboards that I have.  One which is proving difficult is where my pivot expression is already being calculated in a variable.  My pivot expression is set to =$(vCalculatedNumber)

Variable for vCalculatedNumber :

IF(Value=1,

sum([Number]),

//%

IF(Value=2,

num(sum(Number)/sum([Line Total]),'#,##0.0%'),

//rate

IF(Value=3,

Round(sum(Number)/sum([Line Total]), '0.1'),

IF(Value=5,

num(sum(Number)/sum([Line Total]),'#,###.0'),

IF(Value=6,

num(sum([Number])/Pop_Count,'0.0000')

))))

there are also a few hundred indicators and I only need to concatenate about 6 to give three combined indicators.  Can your solution be applied to this too??

Many thanks again for your time.

Tom

jerem1234
Specialist II
Specialist II

You should be able to. Try this for dimension:

=if(match(Ind_No_X, 1, 2), 'Income', if(match(Ind_No_X, 8, 9), 'Discounts',Indicator_X))

This matches the 2 indicators you need to combine into one dimension. Should continue with if statements for whichever indicators you need to combine and have the field that lists the name of indicator last for everything else.

As for expression, if you don't need to do any totals, then this expression should work:

=if(not match(Ind_No_X,1,2,8,9), $(=vCalculatedNumber), concat($(=vCalculatedNumber), ' (',-right(Indicator_X, 1)) & ')')

where 1,2,8,9 are all the fields you are trying to combine.

Try playing around with the formula and see if it gets you anywhere if it doesn't work.

Hope this helps!