Reply
PJ_01
Frequent Visitor

Get the most recent status

I have a table which contains the following data:

DateCategoryProgress_Status
1/14/2024x01
1/15/2024x02
1/15/2024x03
1/17/2024x05
1/18/2024x04
1/21/2024x08
1/23/2024x12
1/16/2024y01
1/22/2024y12


I would like to create a matrix visual which shows the latest Progress_Status for every day I have created the following dax measure:

 

var lastDate=MAX(Calendar[Date])
var lastProgressStatus=MAX(Fact[Progress_Status])
var lastProgressStatusDate=
 CALCULATE(
MAX(Calendar[Date]),
Calendar[Date]<= lastDate,
Fact[Progress_Status] <> BLANK()
)
RETURN
IF(lastProgressStatus==BLANK() || lastProgressStatus =="",
 CALCULATE(
MAX(Fact[Progress_Status]),
Calendar[Date]<= lastProgressStatusDate
),
lastProgressStatus
)

 

 

 

 

This gives me the following result:

Category1/13/20241/14/20241/15/20241/16/20241/17/20241/18/20241/19/20241/20/20241/21/20241/22/20241/23/2024
x 01030305040505080812
y   0101010101011212


However this is not the result i want, because in some cases the statuses are not in ascending order. How do i change my formula to get this result instead?

Category1/13/20241/14/20241/15/20241/16/20241/17/20241/18/20241/19/20241/20/20241/21/20241/22/20241/23/2024
x 01030305040404080812
y   0101010101011212


Thanks a lot for the help !

1 ACCEPTED SOLUTION
Deku
Solution Supplier
Solution Supplier

That is the step one measure, which steps towards the solution. At the end of the blog there are two other version

 

This was one of them

// Using TOPN

VAR currentState = SELECTEDVALUE(States[State])

VAR currentDate = SELECTEDVALUE('Calendar'[Date])+1

RETURN

    COUNTROWS(

        FILTER(

            ALL( data[TestID] ),

            SELECTCOLUMNS(

                TOPN(

                    1,

                    CALCULATETABLE( 

                        FILTER( 

                            'data', 

                            [DateTime] < currentDate

                        )

                        ,REMOVEFILTERS('Calendar'[Date])

                        ,REMOVEFILTERS('States'[State])

                        ),

                    'data'[DateTime], 

                    DESC

                ),

                "Last Value", [State]

                )

            = currentState

            )

        )


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1742266584135.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
PJ_01
Frequent Visitor

Thanks, this was great help.

Deku
Solution Supplier
Solution Supplier

Please see this blog post


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
PJ_01
Frequent Visitor

Thanks, this looks like what I am looking for, however I am not getting the same result as in the blog:
I have downloaded the file from the there and this is what I am getting:

PJ_01_1-1741916465566.png
And this is what it should look like according to the blog:

PJ_01_2-1741916811709.png

It looks like the REMOVEFILTERS function is not working.

Deku
Solution Supplier
Solution Supplier

That is the step one measure, which steps towards the solution. At the end of the blog there are two other version

 

This was one of them

// Using TOPN

VAR currentState = SELECTEDVALUE(States[State])

VAR currentDate = SELECTEDVALUE('Calendar'[Date])+1

RETURN

    COUNTROWS(

        FILTER(

            ALL( data[TestID] ),

            SELECTCOLUMNS(

                TOPN(

                    1,

                    CALCULATETABLE( 

                        FILTER( 

                            'data', 

                            [DateTime] < currentDate

                        )

                        ,REMOVEFILTERS('Calendar'[Date])

                        ,REMOVEFILTERS('States'[State])

                        ),

                    'data'[DateTime], 

                    DESC

                ),

                "Last Value", [State]

                )

            = currentState

            )

        )


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
avatar user

Helpful resources

Announcements
FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)