cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
SianM
Frequent Visitor

Multiple Sorting and Calculating from previous row

Hi All,

 

I am trying to track the occurance of a particular status in my data set over time (per unique ID). 

 

I have been reading a few pages and am worried it is not possible to do what I am trying without query editor. 

 

I am trying to generate a calculated column based on the previous row of my data, but this also requires a custom sort using two level column sort (apparently not possible).

Is there another way I can do this. This is how I build it in excel..... 

1. Sort by;
    a. ID - to group the leases together

    b. Report date - to get their status over time (number of reports)

 

2. Use countif and anested IF statement to check

    a. For the same property,
    b. has the status changed,

    c. if yes, has it changed to 'close out' (the status I am trying to count)

    d. if yes, count as 1. 

 

The results are below, in this snapshot, there are two properties, both that have progressed to closeout over the reporting period. 

 

When I apply this to my data set I can see how many properties closedout over the period. 

 

Is there a way I can do both of these steps in power BI? 

 

calc.JPG


Your help, ideas, suggestions would be greatly appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Multiple Sorting and Calculating from previous row

This video I made may help you https://youtu.be/xN2IRXQ2CvI



* Matt is a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

3 REPLIES 3

Re: Multiple Sorting and Calculating from previous row

This video I made may help you https://youtu.be/xN2IRXQ2CvI



* Matt is a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

Community Support
Community Support

Re: Multiple Sorting and Calculating from previous row

Hi SianM,

 

Based on my analysis, in DAX, you can create a calculate column and use formula like this pattern:

Count Closeout =
IF (
    CALCULATE (
        COUNTROWS ( Table[Milestones Status] ),
        FILTER (
            Table,
            Table[Lease ID] = EARLIER ( Table[Lease ID] )
                && Table[Milestones Status] <> EARLIER ( Table[Milestones Status] )
        )
    )
        <> 0,
    1,
    0
)

Regards,

Jimmy Tao

SianM
Frequent Visitor

Re: Multiple Sorting and Calculating from previous row

Hi @MattAllington,

 

Thank you for your help, this ended up working a treat! 

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors