Forum Discussion

G_Whit-UK's avatar
G_Whit-UK
Helper II
4 years ago
Solved

Multiple Condition If Statements

Hi,   I'm attempting to write a DAX IF statement with multiple conditions using data from two tables.   My primary data set has a list of transaction IDs together with a month end date.  I then h...
  • G_Whit-UK's avatar
    4 years ago

    Here is the solution to the above problem statement.  This is a multi step solution:

    Step 1:  Power Query
    Edit the query underpinning the Primary Data table by creating a new column and merging the "ME Date" and "Transaction ID" fields. 

     

    =Text.Combine({Text.From([Date], "en-GB"), "-", Text.From([Transaction ID], "en-GB")})

     


    As this should be a unique value, this can be further refined by removing any erroneous duplicates.

    Repeat the above process for the "Vendor1" and "Vendor2" tables.

    Step 2: Desktop
    Now that we have unique references in all source tables, we can create a one to one link between the Primary Data table and the two vendor data tables.

    With new tables relationships established, we can now easily add new columns to the Primary Data table using DAX (one column per vendor data table) using the formula: 

     

    Vendor1 Tag = RELATED('Vendor1 Data'[Vendor ID])

     


    We can use similar logic to create a third column to identify any unmatched items using the following DAX formula:

     

    Not Found =
    IF (
    'Primary Data'[Vendor1 Tag] = BLANK ()
    && 'Primary Data'[Vendor2 Tag] = BLANK (),
    "Not found",
    BLANK ()
    )