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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
aanchalshah18
Helper I
Helper I

Compare each row with the next

Hi,

 

I am to make a comparison of each row of an id to the next to check if the consecutive results are the same?

 

How can I do that? Thanks in advance.

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hello @aanchalshah18 ,

See if this blog helps you

https://community.powerbi.com/t5/Community-Blog/Getting-Previous-Values-in-Power-BI-Part-1/ba-p/1143...

Best regards
Harsh Nathani
Have I answered your question? Mark my position as a solution! Appreciate with a Kudos!! (Click the Thumbs button above)

View solution in original post

9 REPLIES 9
V-pazhen-msft
Community Support
Community Support

@aanchalshah18 
Please check the sample, you can crate the column to check whether it repeats with last role, but you need a column of index or date or something else as the filter. 

 

Column = IF([Result]=CALCULATE(MAX([Result]),FILTER('Table',[Index]=EARLIER('Table'[Index])-1)),1,0)

check with previous.JPG


Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for this..

 

In terms of me wanting to compare

 

Id      Missed/Not

1      Missed

1      Missed

1

1

 

So what I want to do is, take a percentage of missed ie. 2/4 = 50%

 

How can I do that?

 

Are you saying this is still unsolved?
Try using divide and All (table[missed/not]) filter for the denominator. This should give you percent.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

amitchandak
Super User
Super User

@aanchalshah18 , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

You can refer how deal with this day vs last as column vs measure in this blog

https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c324...

AllisonKennedy
Super User
Super User

@aanchalshah18

What is the ultimate goal? You can do a remove duplicates in Power Query if you want to get rid of the same results, or you can also refer to this post to try it in Power Query if the DAX you've already been supplied doesn't work for your scenario: https://www.myonlinetraininghub.com/referencing-next-row-power-query

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

harshnathani
Community Champion
Community Champion

HI @aanchalshah18 ,

 

Create a column

 

Previous Value =
VAR _previousvalue =
    MAXX (
        FILTER (
            Table,
            Table[id]
                < EARLIER ( Table[id] )
        ),
        Table[Value]
    )
RETURN
    IF (
        Table[Value] = _previousvalue,
        1,
        0
    )

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

 

Hi Thanks Harsh,

What would table[value] mean here?

Hi @aanchalshah18 ,

 

Table[Value]  is the Value you want to compare.

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

harshnathani
Community Champion
Community Champion

Hello @aanchalshah18 ,

See if this blog helps you

https://community.powerbi.com/t5/Community-Blog/Getting-Previous-Values-in-Power-BI-Part-1/ba-p/1143...

Best regards
Harsh Nathani
Have I answered your question? Mark my position as a solution! Appreciate with a Kudos!! (Click the Thumbs button above)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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