cancel
Showing results for 
Search instead for 
Did you mean: 
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
Super User III
Super User III

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.


Has this post solved your problem? Please mark it as a 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. ?


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


www.excelwithallison.com

amitchandak
Super User IV
Super User IV

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



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

AllisonKennedy
Super User III
Super User III

@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


Has this post solved your problem? Please mark it as a 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. ?


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


www.excelwithallison.com

harshnathani
Super User III
Super User III

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
Super User III
Super User III

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

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Get Ready for Power BI Dev Camp

Power BI Dev Camp - June 24th

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors