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: 
Tina_Bran
Contributor II
Contributor II

Difference the price vs min price

Hi!

I need your help with an expression.

I have this data set:

Tina_Bran_0-1651578921926.png

 

I must to do something like that

Tina_Bran_1-1651578921931.png

 

My purpose is to get the minimum Price of each material, and sum the difference between  the Price and the minimun Price.

Difference= Price – Min. Price

Min. Price= is the minimun Price per material.

Tina_Bran_2-1651578921945.png

 

I will appreciate your help.

 

 

Labels (1)
2 Solutions

Accepted Solutions
Andrei_Cusnir
Specialist
Specialist

Hello,

 

In this use case scenario, you will need to use the "Aggr()" function. Here are the steps that I have followed:

1. I have loaded the dataset:


 

2. I have added a new measure with the expression: Aggr(NODISTINCT Min(price), material)

This will show all the minimum prices per material in a new column in the Table chart

 

3. I have added another measure with the expression: price - Aggr(NODISTINCT Min(price), material)

This will deduct the minimum price per material from the given price of material which will result in an table as you have mentioned in the description:

 

I hope that this information was helpful. In case I have misunderstood the use case scenario, please elaborate in details by providing additional information. However, if it has helped you resolve the issue, please mark it as accepted solution to give further visibility to other community members. 
 

Help users find answers! Don't forget to mark a solution that worked for you! 🙂

View solution in original post

vinieme12
Champion III
Champion III

if you need totals by purchaser

sum(aggr(price-min(total <material>price),purchaser,material,price))

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

4 Replies
Andrei_Cusnir
Specialist
Specialist

Hello,

 

In this use case scenario, you will need to use the "Aggr()" function. Here are the steps that I have followed:

1. I have loaded the dataset:


 

2. I have added a new measure with the expression: Aggr(NODISTINCT Min(price), material)

This will show all the minimum prices per material in a new column in the Table chart

 

3. I have added another measure with the expression: price - Aggr(NODISTINCT Min(price), material)

This will deduct the minimum price per material from the given price of material which will result in an table as you have mentioned in the description:

 

I hope that this information was helpful. In case I have misunderstood the use case scenario, please elaborate in details by providing additional information. However, if it has helped you resolve the issue, please mark it as accepted solution to give further visibility to other community members. 
 

Help users find answers! Don't forget to mark a solution that worked for you! 🙂
Tina_Bran
Contributor II
Contributor II
Author

It works perfectly! Thanks a lot!!!
vinieme12
Champion III
Champion III

if you need totals by purchaser

sum(aggr(price-min(total <material>price),purchaser,material,price))

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Tina_Bran
Contributor II
Contributor II
Author

 It works! Thanks!!