Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can calculated dimensions be used as conditions?

For example:

ABCDresult
< 5K< 4K< 2K< 1K6%
≥ 5K,and< 10K≥ 4K,and< 7K≥ 2K,and< 3K≥ 1K,and< 2K7%
≥ 10K,and< 15K≥ 7K,and< 10K≥ 3K,and< 4K≥ 2K,and< 3K9%
≥ 15K,and< 22K≥ 10K,and< 15K≥ 4K,and< 5K≥ 3K,and< 4K11%
≥ 22K≥ 15K≥ 5K≥ 4K13%

Above is the rule.

If I have some data like this:

TypeAmt
A12000
A26000
A3200000
A41000
B13000
B25000
C11000
C24500
C36000
D1500
D21500
D33500
D44500

And have already grouped by functions:

TypeGroupAmt
A1A2000
A2A6000
A3A200000
A4A1000
B1B3000
B2B5000
C1C1000
C2C4500
C3C6000
D1D500
D2D1500
D3D3500
D4D4500

How can I have the result?(Use many if functions?)

TypeGroupAmtresult
A1A20006%
A2A60007%
A3A20000013%
A4A10006%
B1B30006%
B2B50007%
C1C10006%
C2C450011%
C3C600013%
D1D5006%
D2D15007%
D3D350011%
D4D450013%
12 Replies
SergeyMak
Partner Ambassador
Partner Ambassador

Hi,

If you have same intervals like in case of  D and C, where interval 1k, you can use Class() function.

So you can use IF to calculate depending on group and Class to divide by intervals

Regards,
Sergey
Not applicable
Author

So there is no easier way to deal with A and B?

SergeyMak
Partner Ambassador
Partner Ambassador

As I know only IF...

But I always move these calculations to the load script and have no problem..

In load script you can additionally use predefined intervals in the separate table and use intervalmatch function to assign this classification. But it's better if you need to give the user the possibility to change these intervals without you.

Regards,
Sergey
Not applicable
Author

Sergey,

if you need to resolve rules on the fly, you may:

transform you ranges table into formula during reload:

Re: pick rating on the fly using calculated score

use expression like in color definition here:

Re: Re: Color Code based on Inline Table utilizing two dimensions in that table

You may also try build your lookup using firstsortedvalue().

regards

Darek

SergeyMak
Partner Ambassador
Partner Ambassador

Thanks for sharing, Dariusz.

Very interesting

Regards,
Sergey
Not applicable
Author

Thank you, Sergey and Dariusz.

But I have one more question:

Can calculated dimensions be used for the conditions of expression?

Actually the rule of group is much more complicated(not just use left function),and when I use multiple "IF",I have to copy and paste the "group" formulas many times.Is there an easier way to get the problem solved?

SergeyMak
Partner Ambassador
Partner Ambassador

Hi Joy,

Usually I move the conditional logic from the expression to the load script and model and then use simple expressions like sum(Value). For example I usually put budget and actual data to one table with additional column Type. Or do the same if I have several types like orders, invoices, payments etc.

share a sample of data and I will try to explain ho to do it

because it's really depends on the data and the requirements.

Regards,
Sergey
Not applicable
Author

HI ,Sergey

Thanks for the help. If I share the data, I have to translate many Chinese expression into English.Or You will be difficult to understand the requirements.Can I use variable or set expression to do that?

SergeyMak
Partner Ambassador
Partner Ambassador

As I told before I usually move conditional logic to the script

but actually everything depend on the requirements

Regards,
Sergey