Forum Discussion

SK456's avatar
SK456
Frequent Visitor
3 years ago
Solved

Comparing values in a column and outputting a string

Hi,

So I have a matrix and need to compare two columns and return a string.

 

The 1's are basically a distinct count of a part number on a certain extraction date. So I want to compare between two selected extraction date if Column1 = Column 2 return "No Change", if Column 1 is blank and Column 2 is "1" return "New", if Column 1 is "1" and Column 2 is blank return "Removed"

 

I basically need this replicated but in Power BI as a measure/column

4 Replies

  • MahyarTF's avatar
    MahyarTF
    Memorable Member

    Hi,

    Use the below code to create the new Column :

    Status = if (Sheet20[Col1] = Sheet20[Col2], "No Change",
                if ( ISBLANK(Sheet20[Col1]) && Sheet20[Col2] = 1, "New",
                    if( Sheet20[Col1] = 1 && ISBLANK(Sheet20[Col2]), "Removed")
                   )
            )

     

  • SK456's avatar
    SK456
    Frequent Visitor

    Hi MahyarTF,

    For you the columns are named Col1 and Col2 however in my matrix the columns are the extraction dates which changes depending on the dates selected through the slicer, as you can see in the image. How would I go about this?

    • v-jingzhang's avatar
      v-jingzhang
      Community Support

      Hi SK456 

       

      Do you add Date column to Column of a matrix visual? If so, it's difficult to add an additional column next to the second date column in the same matrix. Once add a field to Values well, it will display in every date column. It cannot show the value as you show in Excel. 

       

      Best Regards,
      Community Support Team _ Jing