Forum Discussion

luizzed's avatar
luizzed
Frequent Visitor
5 years ago
Solved

Conditional with DAX using columns from different tables

Hi!
I have two tables:

dimension

fact

with this relationship

I'm trying to make a measure that when the value of the dimension[Value] column is empty, use the value of the fact[Subvalue] column. I could do this with Power Query or calculated column, but I'm trying with dax, I did this dax meause here, but when the dimension[Value] column value is empty, it returns empty instead of Germany.

 
Conditional Column =
var principal = CALCULATE(LASTNONBLANK('dimension'[Value],TRUE()),CROSSFILTER('dimension'[Index],fact[Index],Both))
var secondary = FIRSTNONBLANK('fact'[Subvalue],true())
RETURN
COALESCE(principal,secondary)

 

how do i get this with DAX measure?

 

  • Measure = 
    IF (
        MAX ( dim[Value] ) = BLANK (),
        CALCULATE (
            MAXX ( FILTER ( 'fact', 'fact'[Index] = MAX ( dim[Index] ) ), 'fact'[Value] )
        ),
        MAX ( dim[Value] )
    )

    luizzed 

     

2 Replies

  • smpa01's avatar
    smpa01
    Community Champion
    Measure = 
    IF (
        MAX ( dim[Value] ) = BLANK (),
        CALCULATE (
            MAXX ( FILTER ( 'fact', 'fact'[Index] = MAX ( dim[Index] ) ), 'fact'[Value] )
        ),
        MAX ( dim[Value] )
    )

    luizzed 

     

  • Hello that such community, I have a similar request, I want to place a UNIQUE value in a "CARD" try with the code that comes in the previous example but did not come out excato what I need.

    My problem is as follows:

    Thank you in advance for your valuable contributions