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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
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

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



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

View solution in original post

3 REPLIES 3
v-yuta-msft
Community Support
Community Support

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

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



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

Hi @MattAllington,

 

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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