Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
linusblomberg
Creator II
Creator II

Dynamically display value based on minimum value in other field

Hi, I'm kind of new to using this forum but I'm drawing blanks here and really hope that someone can get me on the right path.

I have a table with competitor prices on products. Some products are sold by more than one competitior. I wish to create a new table showing only the row (competitor) with the cheapest price. I figured out how to show the lowest price but I can't figure out how to show the competitor based on the CompetitorPrice column

First Table

ItemNoRankCompetitorIndexCompetitor PriceOur PriceDiffOur StockCompetitor
18867919Alpha0,981 6901 729-39In StockIn Stock
18867919Beta1,161 9991 729270In StockIn Stock
18867919Gamma1,612 7901 7291061In StockIn Stock
18867919Delta1,612 7901 7291061In StockIn Stock
18868117Alpha1,002 5802 585-5In StockIn Stock
18868117Beta1,162 9992 585414In StockIn Stock
18868117Gamma1,022 6402 58555In StockIn Stock
1886433Alpha0,75370495-125In StockIn Stock
1886433Delta1,1154949554In StockIn Stock
1886494Alpha1,006896890In StockIn Stock
18866516Alpha0,971 1551 195-40In StockIn Stock
18867320Alpha0,981 5501 579-29In StockIn Stock
18867320Beta1,081 6991 579120In StockIn Stock
18867320Gamma1,011 5901 57911In StockIn Stock
18867320Delta1,392 1901 579611In StockIn Stock

   

Desired Table

ItemNoRankCompetitorIndexCompetitor PriceOur PriceDiffOur StockCompetitor
18867919 0,9816901729-39In Stock
18868117 1,0025802585-5In Stock
1886433 0,75370495-125In Stock
1886494 1,006896890In Stock
18866516 0,9711551195-40In Stock
18867320 0,9815501579-29In Stock

Now,

Price and index columns is calculated on

aggr(Min({$<Competitor-={'OurStore'}>}$(vPrice)),Timestamp, ItemNo))

Where vPrice is a variable containing the price either with or without freight.

So how can I display the corresponding Competitor to that price?

If there are more than one competitor with the cheapest price it is ok to show a blank or any competitor with that price.

I need it to be dynamic and based on the competitors in my selection which is why I haven't just calculated it in the load script.

I'm very grateful for any ideas or suggestions.

1 Solution

Accepted Solutions
Not applicable

Try the firstsortedvalue() expresssion. This returns the value to a corresponding minimum / maximum value in another field.

So in this case you would have the product as the dimension, then

=firstsortedvalue(Competitor,Price) to return the competitor associated with the lowest price.

Erica

View solution in original post

5 Replies
jerem1234
Specialist II
Specialist II

I feel like if Competitor is a dimension in your chart, it should show the corresponding competitor for your chart for that price.

Could you give more info as to the structure of your table? which are dimensions and which are expressions?

May be maxString(Competitor) if its an expression?

Not applicable

Try the firstsortedvalue() expresssion. This returns the value to a corresponding minimum / maximum value in another field.

So in this case you would have the product as the dimension, then

=firstsortedvalue(Competitor,Price) to return the competitor associated with the lowest price.

Erica

linusblomberg
Creator II
Creator II
Author

Hi yes, Competitor is a Dimension in the first chart (is there a way for me to edit my post?)

I've tried max string but that just gives me a competitor that doesn't correspond to that row.

I wanted to try to use

({$<Price*={$(=(aggr(Min({$<Competitor-={OurStore}>}$(vPrice)),Timestamp, ItemNo)))}>}Competitor)

But that only worked when only one item was selected.

linusblomberg
Creator II
Creator II
Author


Thanks Erica, I actually tried the firstsortedvalue() but you are right it does seem to work.

FirstSortedValue(Competitor,$(vPrice))

linusblomberg
Creator II
Creator II
Author

And to remove 'OurStore'

FirstSortedValue({$<Competitor-={'OurStore'}>}Competitor,$(vPrice))

Thanks for quick replies