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: 
hitha1512
Creator
Creator

To pick required Value based on multiple conditions

Hi Team,

Below is sample data I have and I need to calculate the best value based on few condition as below.

1. Check the Minimum rank, if there are more than one row\records, then

2. Check the minimum Tier value, if there are more than one row\records, then

3. Check the minimum date and consider that as Best Value

But Best value should be based on above condition and precedence only, First it has to check the rank, then tier value and then date.

ContractRankTier ValueDate
Premier Inc9428058/05/2019
MedAssets 9300003/24/2019
Vizient 9611508/05/2019
Cardinal Health8428058/23/2019
HealthTrust Purchasing Group8428058/05/2019

 

Result :

ContractRankTier ValueDateBest Value
Premier Inc9428058/05/2019 
MedAssets 9300003/24/2019 
Vizient 9611508/05/2019 
Cardinal Health8428058/23/2019 
HealthTrust Purchasing Group8428058/05/2019TRUE

 

Any help is appreciated!

Regards,

Hitha Dhani

2 Solutions

Accepted Solutions
sunny_talwar

You can try this using Rank() function on top of -(Rank + [Tier Value]/1e5 + Date/1e10) to determine  rank 1... Rank 1 will be your lowest value.

Also, I would need to see an example for what you mean by Tier Value. This is kind of dependent on each value for each section because I am trying to weight them a little differently. But based on possible range of values, we can determine the weights.

View solution in original post

sunny_talwar

Sorry, but are you working on a similar issue or do you work with @hitha1512 ? I just want to make sure I understand how your issue is related to the one in question.

In that case, may be create value like this

Rank*1e10 + [Tier Value]/1e5 + Date/1e10

Multiplied Rank by 10,000,000,000 to make sure Tier Value doesn't end up exceeding Rank (hence adding more weight to Rank).

Do you get the idea? It is all about giving more weight to the field which is first in order of decision making and less weight to the field which is last in order of decision making.

View solution in original post

16 Replies
sunny_talwar

You need this to be done in the script or a front end chart?

hitha1512
Creator
Creator
Author

In script:)
sunny_talwar

May be try something like this

Table:
LOAD *,
	 Rank + [Tier Value]/1e5 + Date/1e10 as Temp;
LOAD * INLINE [
    Contract, Rank, Tier Value, Date
    Premier Inc, 9, 42805, 8/05/2019
    MedAssets , 9, 30000, 3/24/2019
    Vizient , 9, 61150, 8/05/2019
    Cardinal Health, 8, 42805, 8/23/2019
    HealthTrust Purchasing Group, 8, 42805, 8/05/2019
];

Left Join (Table)
LOAD Min(Temp) as Temp,
	 'TRUE' as [Best Value]
Resident Table;

DROP Field Temp;

I created a temp field which just combines the three fields which you use for your rating. I gave Rank the biggest weight and then Tier Value and finally the date field.

Saravanan_Desingh

One more solution in Script.

tab1:
LOAD * INLINE [
    Contract, Rank, Tier Value, Date
    Premier Inc, 9, 42805, 8/05/2019
    MedAssets , 9, 30000, 3/24/2019
    Vizient , 9, 61150, 8/05/2019
    Cardinal Health, 8, 42805, 8/23/2019
    HealthTrust Purchasing Group, 8, 42805, 8/05/2019
];

tab2:
NoConcatenate
LOAD * Resident tab1;

Right Join(tab2)
LOAD Min(Rank) As Rank Resident tab2;

Right Join(tab2)
LOAD Min([Tier Value]) As [Tier Value] Resident tab2;

Right Join(tab2)
LOAD Min(Date) As Date, 'TRUE' As [Best Value] Resident tab2;

Left Join(tab1)
LOAD * Resident tab2;

Drop Table tab2;
Saravanan_Desingh

Output:

commQV12.PNG

Deepak87
Partner - Contributor III
Partner - Contributor III

Hi Sunny,

@sunny_talwar 

is there a way to do it in front end?

Regards,

Deepak K M

hitha1512
Creator
Creator
Author

@sunny_talwar  @Saravanan_Desingh  Thank you. Both the solution work only if the first two conditions output is more than 1 row.

1. Check the Minimum rank, if there are more than one row\records, then

2. Check the minimum Tier value, if there are more than one row\records, then

3. Check the minimum date and consider that as Best Value.

in case the first check for minimum rank holds just one row.... best value should be populated at this level and the next 2 checks should be ignored.

similarly if second check gives one row as out put. last check should be ignored. 

Example :

Raw data :  

ContractRankTier ValueDate
Premier Inc9428058/05/2019
MedAssets 9300003/24/2019
Vizient 9611508/05/2019
Cardinal Health8428058/23/2019

here first check is on minimum rank....which is 8... since its output is just one row, best value will be populated for this row.

ContractRankTier ValueDate
Premier Inc9428058/05/2019
MedAssets 9300003/24/2019
Vizient 9611508/05/2019

here, first check holds 3 records for rank 9, hence this will go to next check for tier value. since the minimum value here is 3000, best value will be populated against this row. 

Any help is appreciated! 🙂

Regards,

Hitha Dhani

sunny_talwar

When I use this data

ContractRankTier ValueDate
Premier Inc9428058/05/2019
MedAssets 9300003/24/2019
Vizient 9611508/05/2019
Cardinal Health8428058/23/2019

 

and run this script

Table:
LOAD *,
	 Rank + [Tier Value]/1e5 + Date/1e10 as Temp;
LOAD * INLINE [
    Contract, Rank, Tier Value, Date
    Premier Inc, 9, 42805, 8/05/2019
    MedAssets , 9, 30000, 3/24/2019
    Vizient , 9, 61150, 8/05/2019
    Cardinal Health, 8, 42805, 8/23/2019
];

Left Join (Table)
LOAD Min(Temp) as Temp,
	 'TRUE' as [Best Value]
Resident Table;

DROP Field Temp;

I get this

image.png

When I use this data

ContractRankTier ValueDate
Premier Inc9428058/05/2019
MedAssets 9300003/24/2019
Vizient 9611508/05/2019

 

and I use this script

Table:
LOAD *,
	 Rank + [Tier Value]/1e5 + Date/1e10 as Temp;
LOAD * INLINE [
    Contract, Rank, Tier Value, Date
    Premier Inc, 9, 42805, 8/05/2019
    MedAssets , 9, 30000, 3/24/2019
    Vizient , 9, 61150, 8/05/2019
];

Left Join (Table)
LOAD Min(Temp) as Temp,
	 'TRUE' as [Best Value]
Resident Table;

DROP Field Temp;

I get this

image.png

All I have changed is the raw data and it looks the true shows up for the same row where you want it to be, right? Not sure if I am missing something?

sunny_talwar

Yes this is doable on the front end as well