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
LostintheBIu
Helper I
Helper I

Compared this month status with previous month status.

Hello everyone,

 

It is the first time when I have to do more complex things with PowerBI and I got stuck on this one.

 

I have a set of data with the following columns: ID, Date, Stage, Status. Important to notice that this is kind of a panel data where we follow observations (projects) over a few months. The data will be updated monthly and this is why we want to add a new column called "Status previous month" that will tell us the status that a project had in the previous month. This will enable us to see what projects advance and what projects make no progress.

 

For example, in the screenshot below you can see projects that were updated on 18.08.2020 and 18.09.2020 (just an example). If we look at the first column, ID 800680 we can see that the status changes from one month to another (from approved to active), therefore the value for the new column in the highlighted raw should be "Approved" because that was the status of that project in the previous month. Since 18.08.2020 is the first date with data available, the "previous status" for these rows should just show "N/A".  Once the "Previous Status" column is created, I would like to add a new one called "Progress" where based on the new status and previous status, I can see what the progress was. Perhaps this will be done with some IF statements.

 

LostintheBIu_2-1597930962166.png

 

I have read lots of posts on this topic and tried solutions involving functions such as "PreviousMonth" or "Earlier" but doesn't seem to match my needs.

 

Thanks a lot for helping and feel free to ask if more details are needed

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @LostintheBIu ,

Based on your description, I have added another row on ID 800680

result.png

You can create a calculated column like this:

 

Status previous month = 
IF (
    CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[ID] ) ) > 1,
    IF (
        'Table'[Date]
            = CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[ID] ) ),
        CALCULATE (
            MAX ( 'Table'[Status] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Date] = EARLIER ( 'Table'[Date] ) )
        ),
        "N/A"
    ),
    "N/A"
)

 

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yingjl
Community Support
Community Support

Hi @LostintheBIu ,

Based on your description, I have added another row on ID 800680

result.png

You can create a calculated column like this:

 

Status previous month = 
IF (
    CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[ID] ) ) > 1,
    IF (
        'Table'[Date]
            = CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[ID] ) ),
        CALCULATE (
            MAX ( 'Table'[Status] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Date] = EARLIER ( 'Table'[Date] ) )
        ),
        "N/A"
    ),
    "N/A"
)

 

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@LostintheBIu , try , new columns

maxx(filter(table, [ID] =earlier([ID]) && eomonth([Date],0) = eomonth(earlier([Date]),-1)),[Status])

ot

maxx(filter(table, [ID] =earlier([ID]) && eomonth([Date],0) = eomonth(earlier([Date]),-1)),earlier([Status]))

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.