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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Multiple Number Format in Single Expression

Is it possible to format data in a column based on what the sub dimension is?

For example, I want the following data to

DVPMetricTypeCYLY% Diff
C. ParsonsTotal Revenue10000900011%
C. ParsonsDiscounts-2000-5000-60.00%
C. ParsonsWrite Offs-500-1000-50.00%
C. ParsonsSq Ft Occupancy75.7581.82-7.42%
C. ParsonsFull Price Rentals25810-


formatted as

DVPMetricTypeCYLY% Diff
C. ParsonsTotal Revenue$10,000$9,00011.11%
C. ParsonsDiscounts($2,000)($5,000)-60.00%
C. ParsonsWrite Offs($500)($1,000)-50.00%
C. ParsonsSq Ft Occupancy75.75%81.82%-7.42%
C. ParsonsFull Price Rentals25810-


I was able to format properly by having each metric type as an individual expression, but in doing that I could not generate the % Diff column because that column is a delta of the CY and LY columns.

1 Solution

Accepted Solutions
Not applicable
Author

I had a similar situation where I wanted one of the partial sums in a pivot table to be a percent while everything else was a number. I ended up cheating and concatenating the % sign to the end of the expression.

Something like:

If(MetricType='Sq Ft Occupancy', Exp & '%', Exp)


It also looks like you have different ways of signifying negative in there and also different rounding. You could probably still use something similar, but you'd have to get a little more creative to handle those two issues. For the negative on the percentage, you could use a conditional to put a minus in front if it was negative and then display the absolute value.

If you could make the two displays a little more alike (- for negatives on both), it could simplify things.

View solution in original post

3 Replies
Not applicable
Author

I had a similar situation where I wanted one of the partial sums in a pivot table to be a percent while everything else was a number. I ended up cheating and concatenating the % sign to the end of the expression.

Something like:

If(MetricType='Sq Ft Occupancy', Exp & '%', Exp)


It also looks like you have different ways of signifying negative in there and also different rounding. You could probably still use something similar, but you'd have to get a little more creative to handle those two issues. For the negative on the percentage, you could use a conditional to put a minus in front if it was negative and then display the absolute value.

If you could make the two displays a little more alike (- for negatives on both), it could simplify things.

Not applicable
Author

I actually tried that in and it didn't work because I made another error when using that process.

In order to use the "custom" number formatting, you need to leave the number format setting at expression default. That was my mistake.

Thanks for giving me that push to figure it out.

johnw
Champion III
Champion III

Rather than changing a number into text, I would simply set the formatting. For example (untested):

num(expression,pick(match(column
,'Some Number','Some Dollar Amount' ,'Some Percentage')
,'#,##0' ,'$#,##0.00;($#,##0.00)','#,##0.00%')

And in your case, it looks like you probably have different expressions for each, so you could do something like this instead (untested):

if(column='Some Number' ,num(some numeric expression ,'#,##0')
,if(column='Some Dollar Amount',num(some dollar expression ,'$#,##0.00;($#,##0.00)')
,if(column='Some Percentage' ,num(some percentage expression,'#,##0.00%'))))