Forum Discussion
Comparing values from two different table on table visual
Greetings,
I'm struggling to find a solution to my problem.
I have two related tables as following:
I'm trying to calculate this measure that i need to insert inside a table visual.
var a = MAX(Table1[Durata])
var b = MAX(Table2[soglie])
return
SWITCH(TRUE,
a > b , -1,
a < b , 1,
0)
This is the table, as you can see the relation between Table1.key and Table2.key is working as expected.
And this is the result adding the measure.
What exactly I'm not understanding? Of course this is related to switch and if function..... but I'm not getting it.
Any help would be much appreciated
There must be a better way of doing this, but the below seems to work
Measure = var Table2Keys = SUMMARIZE( Table1, Table2[_kEY]) var CurrentKey = SELECTEDVALUE(Table1[_kEY]) RETURN IF( CurrentKey IN Table2Keys, var a = MAX(Table1[Durata]) var b = MAX(Table2[soglie]) return SWITCH(TRUE, a > b , -1, a < b , 1, 0) )
8 Replies
- johnt75Super User
Having a bidirectional many-to-one relationship is usually a bad idea, try changing it to a single direction if you can.
- AnonymousNot applicable
i already try:
and this does not change the result....
if in the measure i m not using the switch or if function, it's working properly.
Any idea??- johnt75Super User
Can you copy the code generated for the table visual from Performance Analyzer and paste it in here? Or can you share a PBIX file with any confidential info removed ?