Forum Discussion

ASuhaji's avatar
ASuhaji
Frequent Visitor
3 years ago

DAX Measure: Sum numbers from another table

Hello Everyone,

 

A simple measure question, but I can't find any solution.

 

A short example. I have 2 tables with these values:

 

And this is what I want to achieve:

 

It seems to be logical but it doesn't work:

Measure =
    VAR Table1_Sum = SUM(Table1[Count])
    VAR Table2_Sum = SUM(Table2[Count])
   
    RETURN
        DIVIDE(Table1_Sum, Table2_Sum)
 
Or: 
Measure =
    VAR Table2_Sum = SUM(Table2[Count])
    VAR Table2_ID = MAX(Table2[Id])
   
    RETURN
        CALCULATE(
            DIVIDE(SUM(Table1[Count]), Table2_Sum),
            Table1[Id] = Table2_ID
        )
 
Thank you for your help in advance.

1 Reply

  • vanessafvg's avatar
    vanessafvg
    Community Champion

    the simple solution is how you model this data

     

    create a bridge table, which is the unique  list of all your id's  in both tables, and then hook up both of tables to to the unique id table. 

    then using your  new unique values of id's table, you place the ids from that table on the visual and the values you want from each of the tables and you should be able to compare.

     

    if you give data in text format i can create it for you, bit it requires data in a usuable text format to copy and paste, or provide your pbix.