Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

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.

 

Supplier Key : Dataset

Output required : Desired Output

 

Suplier KeyOutput required
4D2B1234567 - Supplier  - 11
4D2B1234567 - Supplier  - 10
4D2B1234567 - Supplier  - 10
4D2B1234567 - Supplier  - 10
4D2B1234567 - Supplier  - 10
4D2B1234567 - Supplier  - 10
4D2B1234567 - Supplier  - 10
4D2B1234567 - Supplier  - 10
884B1234567 - Supplier  - 11
884B1234567 - Supplier  - 10
884B1234567 - Supplier  - 10
4D2B1234567 - Supplier  - 11
4D2B1234567 - Supplier  - 10
4D2B1234567 - Supplier  - 10
4D2B1234567 - Supplier  - 10
4D2B1234567 - Supplier  - 10
4D2B1234567 - Supplier  - 21
4D2B1234567 - Supplier  - 20
T01B1234567 - Supplier  - 31
661B1234567 - Supplier  - 41
462B1234567 - Supplier  - 51
477B1234567 - Supplier  - 61
430B1234567 - Supplier  - 71
477B1234567 - Supplier  - 81
4A5B1234567 - Supplier  - 91
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
4A5B1234567 - Supplier  - 90
304B1234567 - Supplier  - 101
4A5B1234567 - Supplier  - 111
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
4A5B1234567 - Supplier  - 110
T01B1234567 - Supplier  - 121
T01B1234567 - Supplier  - 120
T01B1234567 - Supplier  - 120
T01B1234567 - Supplier  - 120
T01B1234567 - Supplier  - 120
T01B1234567 - Supplier  - 120
430B1234567 - Supplier  - 131
430B1234567 - Supplier  - 130
T01B1234567 - Supplier  - 141
468B1234567 - Supplier  - 151
468B1234567 - Supplier  - 150
468B1234567 - Supplier  - 150
468B1234567 - Supplier  - 150
468B1234567 - Supplier  - 150
889B1234567 - Supplier  - 161
889B1234567 - Supplier  - 160
889B1234567 - Supplier  - 160
T01B1234567 - Supplier  - 171
468B1234567 - Supplier  - 181
304B1234567 - Supplier  - 191
304B1234567 - Supplier  - 190
614B1234567 - Supplier  - 201
614B1234567 - Supplier  - 200
614B1234567 - Supplier  - 200
614B1234567 - Supplier  - 200
614B1234567 - Supplier  - 200
614B1234567 - Supplier  - 200
430B1234567 - Supplier  - 211
430B1234567 - Supplier  - 210
468B1234567 - Supplier  1 1
4H8B1234567 - Supplier  21
4H8B1234567 - Supplier  20
606B1234567 - Supplier  31
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
606B1234567 - Supplier  30
468B1234567 - Supplier  41
456B1234567 - Supplier  51
468B1234567 - Supplier  61
525B1234567 - Supplier  71
468B1234567 - Supplier  81
468B1234567 - Supplier  80
468B1234567 - Supplier  80
468B1234567 - Supplier  80
468B1234567 - Supplier  80
456B1234567 - Supplier  91
472B1234567 - Supplier  101
472B1234567 - Supplier  100
472B1234567 - Supplier  100
T01B1234567 - Supplier  111
T01B1234567 - Supplier  110
T01B1234567 - Supplier  110
456B1234567 - Supplier  121
T01B1234567 - Supplier  131
4H8B1234567 - Supplier  141
4H8B1234567 - Supplier  140
4H8B1234567 - Supplier  140
4H8B1234567 - Supplier  140
4H8B1234567 - Supplier  140
4H8B1234567 - Supplier  140

 

Thanks

Allwin

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@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 )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

1 REPLY 1
parry2k
Super User
Super User

@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 )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.