Forum Discussion

pjdsh's avatar
pjdsh
Icon for Helper I rankHelper I
7 years ago
Solved

Compare Two Columns from two tables and Get result

Hi,   I am new to DAX and I need help in writing dax query for comparing two columns from two tables and get a value based on the comparision.   Data for   Table 1                              ...
  • jdbuchanan71's avatar
    jdbuchanan71
    7 years ago

    Hello pjdsh ,

    We can add an index column to your Table1 that will keep the visual from grouping the category (A, B, C, etc).

    In the query editor, add a step to Add Column > Index

    Then, in our Table1 we can pull over the value from Table2.  The two tables have to be related on Column1.

    Then in Table1 we add the calculated column to pull over the value and put 0 in the blanks.

    Value = 
    VAR TheValue = RELATED(Table2[Value])
    RETURN 
    IF ( ISBLANK ( TheValue ), 0, TheValue )

    In our visual we add the index, column1 and value all from Table1 and you can make the index column skinny enough you don't see it, you just have to turn off wordwrap on headers and values.

    I uploaded my sample file here for you to take a look at.  https://www.dropbox.com/s/fvgv5uhdipjzas8/RelatedTable.pbix?dl=0