Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

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.     ...
  • johnt75's avatar
    johnt75
    3 years ago

    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)
    )