Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

IF Clause, get value from another table

Hello, For years, I have worked with one big table containing all sorts of information from my marketing campaigns: impressions, link clicks, sales, etc. Every campaign has a different objective, an...
  • smpa01's avatar
    4 years ago

    Anonymous  you can write a measure like this

    Measure =
    VAR _obj =
        MAX ( 'CAMPAIGN INDEX'[Objective] )
    VAR _LinkClicks =
        CALCULATE (
            MAX ( 'LINK CLICKS'[Link Clicks] ),
            FILTER (
                'LINK CLICKS',
                ( 'LINK CLICKS'[Campaign ID], 'LINK CLICKS'[Objective] )
                    IN SUMMARIZE (
                        'CAMPAIGN INDEX',
                        'CAMPAIGN INDEX'[Campaign ID],
                        'CAMPAIGN INDEX'[Objective]
                    )
            )
        )
    VAR _Purchase =
        CALCULATE (
            MAX ( PURCHASES[Purchases] ),
            FILTER (
                PURCHASES,
                ( PURCHASES[Campaign ID], PURCHASES[Objective] )
                    IN SUMMARIZE (
                        'CAMPAIGN INDEX',
                        'CAMPAIGN INDEX'[Campaign ID],
                        'CAMPAIGN INDEX'[Objective]
                    )
            )
        )
    RETURN
        SWITCH ( TRUE (), _obj = "Traffic", _LinkClicks, _obj = "Sales", _Purchase )