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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

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
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors