Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Merge Visuals Containing Different Currencies

Hi,

 

I have 2 different visuals using different tables as shown. 


I want to merge them into one but my problem is their currencies are different so when the user moved from one account to another  it must show the right currency.

 

Thanks...tksnota

 

 

 

 

 

 

 

  • Hi Anonymous 

     

    This is why dimension tables are essential. Directly linking two fact tables isn't ideal because they often have different columns or column values. Instead, create a table that combines the currencies from both tables, then establish one-to-many relationships between this new table and the fact tables.

     

    Sample Calculated table

    CurrencyTable =
    -- Step 1: Create a table containing only the 'Currency' column from Table1
    VAR Tbl1 =
        SELECTCOLUMNS (
            Table1,
            -- Source table
            "Currency", -- Column name in the result
            Table1[Currency] -- Column to extract
        ) -- Step 2: Create a table containing only the 'Currency' column from Table2
    VAR Tbl2 =
        SELECTCOLUMNS (
            Table2,
            -- Source table
            "Currency", -- Column name in the result
            Table2[Currency] -- Column to extract
        ) -- Step 3: Combine Tbl1 and Tbl2, remove duplicates, and return the result
    RETURN
        DISTINCT ( UNION ( Tbl1, -- First table
                Tbl2 -- Second table
                ) )
    

     

2 Replies

  • Hi Anonymous 

     

    This is why dimension tables are essential. Directly linking two fact tables isn't ideal because they often have different columns or column values. Instead, create a table that combines the currencies from both tables, then establish one-to-many relationships between this new table and the fact tables.

     

    Sample Calculated table

    CurrencyTable =
    -- Step 1: Create a table containing only the 'Currency' column from Table1
    VAR Tbl1 =
        SELECTCOLUMNS (
            Table1,
            -- Source table
            "Currency", -- Column name in the result
            Table1[Currency] -- Column to extract
        ) -- Step 2: Create a table containing only the 'Currency' column from Table2
    VAR Tbl2 =
        SELECTCOLUMNS (
            Table2,
            -- Source table
            "Currency", -- Column name in the result
            Table2[Currency] -- Column to extract
        ) -- Step 3: Combine Tbl1 and Tbl2, remove duplicates, and return the result
    RETURN
        DISTINCT ( UNION ( Tbl1, -- First table
                Tbl2 -- Second table
                ) )