Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

DAX Compare text data in same column

Hi All,   Need help for the below sample dataset. In excel we use the IF cond "=IF(A2=A1,0,1)"to retrive the Output.   Kindly let me know how can i get the same using DAX (Column) in Power BI.  ...
  • parry2k's avatar
    7 years ago

    Anonymous add index column in your table in power query to find our previous row and then you can use that to calcuate the desired output

     

    Match = 
    VAR __prevRow = CALCULATE( MAX( 'Table'[Index] ) ) - 1
    VAR __PrevRowValue = CALCULATE( MAX( 'Table'[Suplier Key] ), 'Table'[Index] = __prevRow )
    VAR __currRowValue = CALCULATE( MAX( 'Table'[Suplier Key] ) )
    RETURN
    IF( __currRowValue = __PrevRowValue, 0, 1 )