Forum Discussion
Compare Multiple Rows to Each Other and Lookup
- 1 year ago
Hi Dilbertfan,
The matrix solution is pretty easy to achieve.
You will need two non-related Dataset tables, two non-synched slicers and a measure like the one below.
_lookupMeasure = VAR ds1 = SELECTEDVALUE(Datasets[Name]) VAR ds2 = SELECTEDVALUE('Datasets 2'[Name]) VAR s1 = SELECTEDVALUE(Datasets[Sensitivity]) VAR s2 = SELECTEDVALUE('Datasets 2'[Sensitivity]) RETURN IF ( ds1 <> ds2, MAXX ( FILTER ( Lookup, Lookup[Dataset 1] = s1 && Lookup[Dataset 2] = s2 ), [Result] ) )Please check the Musings tab of your file modified by me.
Best Regards,
Alexander
- 1 year ago
The list solution can be achieved with the help of the same measure and specific settings in a matrix.
Best Regards,
Alexander
Hi Alexander.
Thanks so much for taking the time to respond. Both solutions are great and exactly what I need - didnt realise it was that "simple" :-).
Strangely enough, I had also solved it in another way last night using CROSSJOIN between the two disconneted tables to create a calculated table with a combination of all entries, and then using calculated column lookup, but this solution is far simpler and avoids having a calculated table in it with ~4m rows :-)!!
Just a quick question for my knowledge barritown - you have used SELECTEDVALUE, but have selected multiple values in the table. I thought SELECTEDVALUE was only useful when one thing was selected? How is it passing multiple values into the Lookup table to filter it?
I get that the measure is acting on the row context in the lookup table, but how does it know which one of the values selected to apply to that row?
Thanks for this
Rich
Hi Rich,
In each matrix cell there will be only one value for this function. If you'll imagine putting SELECTEDVALUE in a matrix cell, you will see that it can get only one value from Table1 and Table2.
Best Regards,
Alexander
- Dilbertfan1 year agoFrequent Visitor
Thanks barritown - great of you to explain.
Makes sense, just initially hard to get your head around - I sort of knew this, but it is the act of selecting 4 records in the slicer, which is throwing me off. So in the context of the table or matrix it works, but if you tried to use SELECTEDVALUE in a card, then it would break as you dont have the filter context to bring it to a single value?
Thanks again
Rich
- barritown1 year agoSolution Sage
My pleasure. 🙂
Yup, in case you use it in a card, the solution will work only your slicers allows only one value to be selected.
Best Regards,
Alexander