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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
stellaliu
Regular Visitor

Compare if the values of two adjacent rows are the same.

Hi,

 

I was stuck in comparing if the values of two adjacent rows are the same.

 

I have a table like below. Column A,B,C are known, and I want to calculate for Column D. If in Excel, my equation for D3 should be:

=IF($B3="A","",IF($B3="B",IF(C3=C2,"","check"),"")

 

q.PNG

 

Could you please help me to translate it into a PowerBI language? Thank you very much!

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @stellaliu

 

Try this column

 

Status =
VAR previousQuantity =
    CALCULATE (
        SUM ( Table1[Quantity] ),
        FILTER ( Table1, Table1[#] = EARLIER ( Table1[#] ) - 1 )
    )
RETURN
    IF ( Table1[Types] = "B" && Table1[Quantity] <> previousQuantity, "Check" )

View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

Hi @stellaliu

 

Try this column

 

Status =
VAR previousQuantity =
    CALCULATE (
        SUM ( Table1[Quantity] ),
        FILTER ( Table1, Table1[#] = EARLIER ( Table1[#] ) - 1 )
    )
RETURN
    IF ( Table1[Types] = "B" && Table1[Quantity] <> previousQuantity, "Check" )

Hi,

 

Thank you very much! It definatelly makes sense!

 

But what if I don't have the first column with serial numbers? Are there any ways to revise the equation, or any ways to add a new column with serial numbers to my existed table?

 

Stella

Yes

You can add an index column from query editor's.. "ADD Column" tab

Perfect! Thank you very much!!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.