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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Quazanic
Frequent Visitor

Reference Date to monitor just the last condition before that

Hi,

 

I have a table in PowerBI (from sharepoint list), includes columns: Name, Status and Date.
Every person has more rows based on their condition in time.
There is no shorting on columns, maybe the Date.

 

Task:
If I define a reference date, best would be a slicer; then the function is choosing the row pro Name where the date is the closest one to the reference date, but equal or before that.
If one of the chosen row includes "no" Status, then it needs to be hidden, it doesn't matter that the Name has a "yes" Status earlier.

  • (So I dont need just the "yes" status will be monitored and the closest date will be shown - it would be too easy.)

 

In MS Access I created a frontend and prepared a query with the function above, working well with different reference date, this function should be implemented in powerBI visual table.

Date in mm/dd/yyyy, and 3 examples how it should work: 

 

PowerBI_DataOnTime.jpg

I hope you can help me

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Quazanic ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a date dimension table (Please DO NOT create any relationship between the fact table and date dimension table)

yingyinr_2-1678861933410.png

2. Create a measure as below 

Flag = 
VAR _seldate =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _seltdate =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _selname =
    SELECTEDVALUE ( 'Table'[Name] )
VAR _selstatus =
    SELECTEDVALUE ( 'Table'[Status] )
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Name] = _selname
                && 'Table'[Date] <= _seldate
        )
    )
RETURN
    IF ( _seltdate = _maxdate && _selstatus = "yes", 1, 0 )

3. Create a visual and apply the visual-level filter on the visual with the condition(Flag is 1)

yingyinr_3-1678862017057.png

 

If the above one can't help you, please provide some raw data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Quazanic ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a date dimension table (Please DO NOT create any relationship between the fact table and date dimension table)

yingyinr_2-1678861933410.png

2. Create a measure as below 

Flag = 
VAR _seldate =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _seltdate =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _selname =
    SELECTEDVALUE ( 'Table'[Name] )
VAR _selstatus =
    SELECTEDVALUE ( 'Table'[Status] )
VAR _maxdate =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Name] = _selname
                && 'Table'[Date] <= _seldate
        )
    )
RETURN
    IF ( _seltdate = _maxdate && _selstatus = "yes", 1, 0 )

3. Create a visual and apply the visual-level filter on the visual with the condition(Flag is 1)

yingyinr_3-1678862017057.png

 

If the above one can't help you, please provide some raw data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Many thanks for your description and the attached file helps a lot.

Quazanic
Frequent Visitor

I create a measure:

Max Date =

CALCULATE(MAXX(FILTER(table, table[Date]), table[Date]), ALL(table[Status]))

 

In visual table I put Name, Max Date, Status

 

I can use a slicer, and the table working but there is an interesting failure. 

If the closest Date before the Reference Date has "no" Status, then this row is duplicated with a "yes" Staus as well; and what is really strange that this duplicated fake row has same Date what is belong to the "no" Status

 

How I could eliminate the fake "yes" rows?

 

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.