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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

How to Return the Latest Revisions for Each Document

Hello everyone,

I'm working on a Power BI project, and I have an extensive data table containing information about engineering documents. Each document has multiple revisions, and I would like to create a table that displays not only the latest revisions for each document but also the first occurrence when a document appears with a specific revision. There's an important detail to note: with each document list submission, the records repeat, so it's essential to return not only the highest revision but also the first time the document appears with a particular revision.

I've tried some approaches using measures and calculated columns, but I haven't been able to achieve the desired result.

Here are the details of my table:

  • Table Name: [f_LDs]
  • Column that identifies when the document list was sent: [f_LDs[Dt. LD]]
  • Column that identifies the documents: [f_LDs[Nº Alunorte]]
  • Column representing the revision number: [LDs[Revisão]]

Gabe_Moreira_0-1696601809515.png

 

In the exemple above i'd like to be returned only the last row info

 

Could someone please guide me on how to accomplish this task in Power BI? What DAX formula should I use, or what steps should I follow in Power Query to achieve this goal?

Any help or suggestions will be greatly appreciated. Thank you in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

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

1. Create a measure as below

Flag = 
VAR _seldate =
    SELECTEDVALUE ( 'f_LDs'[Dt. LD] )
VAR _rev =
    SELECTEDVALUE ( 'f_LDs'[Revisão] )
VAR _doc =
    SELECTEDVALUE ( 'f_LDs'[Nº Alunorte] )
VAR _maxdate =
    CALCULATE (
        MAX ( 'f_LDs'[Dt. LD] ),
        FILTER ( ALLSELECTED ( 'f_LDs' ), 'f_LDs'[Nº Alunorte] = _doc )
    )
VAR _predate =
    CALCULATE (
        MAX ( 'f_LDs'[Dt. LD] ),
        FILTER (
            ALLSELECTED ( 'f_LDs' ),
            'f_LDs'[Nº Alunorte] = _doc
                && 'f_LDs'[Dt. LD] < _maxdate
                && NOT ( ISBLANK ( 'f_LDs'[Dt. LD] ) )
        )
    )
RETURN
    IF ( _seldate IN { _predate, _maxdate }, 1, 0 )

Or create a calculated column:

Column = 
VAR _maxdate =
    CALCULATE (
        MAX ( 'f_LDs'[Dt. LD] ),
        FILTER ( 'f_LDs', 'f_LDs'[Nº Alunorte] = EARLIER ( 'f_LDs'[Nº Alunorte] ) )
    )
VAR _predate =
    CALCULATE (
        MAX ( 'f_LDs'[Dt. LD] ),
        FILTER (
            'f_LDs',
            'f_LDs'[Nº Alunorte] = EARLIER ( 'f_LDs'[Nº Alunorte] )
                && 'f_LDs'[Dt. LD] < _maxdate
                && NOT ( ISBLANK ( 'f_LDs'[Dt. LD] ) )
        )
    )
RETURN
    IF ( 'f_LDs'[Dt. LD] IN { _predate, _maxdate }, 1, 0 )

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

vyiruanmsft_0-1696831527026.png

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

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

1. Create a measure as below

Flag = 
VAR _seldate =
    SELECTEDVALUE ( 'f_LDs'[Dt. LD] )
VAR _rev =
    SELECTEDVALUE ( 'f_LDs'[Revisão] )
VAR _doc =
    SELECTEDVALUE ( 'f_LDs'[Nº Alunorte] )
VAR _maxdate =
    CALCULATE (
        MAX ( 'f_LDs'[Dt. LD] ),
        FILTER ( ALLSELECTED ( 'f_LDs' ), 'f_LDs'[Nº Alunorte] = _doc )
    )
VAR _predate =
    CALCULATE (
        MAX ( 'f_LDs'[Dt. LD] ),
        FILTER (
            ALLSELECTED ( 'f_LDs' ),
            'f_LDs'[Nº Alunorte] = _doc
                && 'f_LDs'[Dt. LD] < _maxdate
                && NOT ( ISBLANK ( 'f_LDs'[Dt. LD] ) )
        )
    )
RETURN
    IF ( _seldate IN { _predate, _maxdate }, 1, 0 )

Or create a calculated column:

Column = 
VAR _maxdate =
    CALCULATE (
        MAX ( 'f_LDs'[Dt. LD] ),
        FILTER ( 'f_LDs', 'f_LDs'[Nº Alunorte] = EARLIER ( 'f_LDs'[Nº Alunorte] ) )
    )
VAR _predate =
    CALCULATE (
        MAX ( 'f_LDs'[Dt. LD] ),
        FILTER (
            'f_LDs',
            'f_LDs'[Nº Alunorte] = EARLIER ( 'f_LDs'[Nº Alunorte] )
                && 'f_LDs'[Dt. LD] < _maxdate
                && NOT ( ISBLANK ( 'f_LDs'[Dt. LD] ) )
        )
    )
RETURN
    IF ( 'f_LDs'[Dt. LD] IN { _predate, _maxdate }, 1, 0 )

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

vyiruanmsft_0-1696831527026.png

Best Regards

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors