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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Lakshmi123
New Member

Get an Latest date Records

Hi ,

i created below table by using 3 tables : 

dim TableA- state

fact TableB- num (num of records), diff(measure)

dim TableC- date_dt

 

statenumdiffdate_dt
alabama100010020-Feb-25
alaska20001027-Feb-25
alaska220020027-Mar-25
arizona150010022-Feb-25
arizona1000-50027-Mar-25
arizona2000100020-Apr-25
california300010022-Jan-25
california4000100022-Feb-25
california1000-300027-Mar-25
california5000400020-Apr-25

I need to generate the output shown below, where each state appears only once with its latest date  without any repetition.

Could you please guide me on how to create a measure or column in Power BI to achieve this result instead of the above output?

 

required output:

statenumdiffdate_dt
alabama100010020-Feb-25
alaska220020027-Mar-25
arizona2000100020-Apr-25
california5000400020-Apr-25

 

Thank you in advance.

Lakshmi

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I tried to create a sample pbix file like below, and please check the below picture and the attached pbix file.

I used INDEX dax function in the measures.

Jihwan_Kim_1-1744254699667.png

 

 

Jihwan_Kim_0-1744254599576.png

 

INDEX function (DAX) - DAX | Microsoft Learn

 

Num expected result: = 
VAR _t =
    CALCULATETABLE (
        SUMMARIZE ( 'fact', 'calendar'[Date] ),
        REMOVEFILTERS ( 'calendar'[Date] )
    )
VAR _latestdate =
    INDEX ( 1, _t, ORDERBY ( 'calendar'[Date], DESC ) )
RETURN
    IF (
        HASONEVALUE ( state[state] ),
        CALCULATE (
            SUM ( 'fact'[num] ),
            KEEPFILTERS ( 'calendar'[Date] = _latestdate )
        )
    )

 

Diff expected result: = 
VAR _t =
    CALCULATETABLE (
        SUMMARIZE ( 'fact', 'calendar'[Date] ),
        REMOVEFILTERS ( 'calendar'[Date] )
    )
VAR _latestdate =
    INDEX ( 1, _t, ORDERBY ( 'calendar'[Date], DESC ) )
RETURN
    IF (
        HASONEVALUE ( state[state] ),
        CALCULATE (
            SUM ( 'fact'[diff] ),
            KEEPFILTERS ( 'calendar'[Date] = _latestdate )
        )
    )

 



Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



View solution in original post

5 REPLIES 5
v-sgandrathi
Community Support
Community Support

Hi @Lakshmi123,

Thank you @Jihwan_Kim and @shafiz_p for your response.

 

Has your issue been resolved?If the response provided by the community member addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.

If yes, kindly accept the useful reply as a solution and give us Kudos. It would be appreciated.

 

Thank you for your understanding!

Hi @Lakshmi123,

 

As we did not get a response, may I know if the above reply could clarify your issue, or could you please help confirm if we may help you with anything else?

 

And if the provided information meets your requirements, you can Accept the solution and also give Kudos on that reply. It helps other users who are searching for this same information and find the information.

 

Your understanding and patience will be appreciated.

Hi @Lakshmi123,

 

I wanted to follow up on our previous suggestions regarding the issue. We would love to hear back from you to ensure we can assist you further.

If our response has addressed your query, please accept it as a solution and give a ‘Kudos’ so other members can easily find it. Please let us know if there’s anything else we can do to help.

 

Thank you.

Jihwan_Kim
Super User
Super User

Hi,

I tried to create a sample pbix file like below, and please check the below picture and the attached pbix file.

I used INDEX dax function in the measures.

Jihwan_Kim_1-1744254699667.png

 

 

Jihwan_Kim_0-1744254599576.png

 

INDEX function (DAX) - DAX | Microsoft Learn

 

Num expected result: = 
VAR _t =
    CALCULATETABLE (
        SUMMARIZE ( 'fact', 'calendar'[Date] ),
        REMOVEFILTERS ( 'calendar'[Date] )
    )
VAR _latestdate =
    INDEX ( 1, _t, ORDERBY ( 'calendar'[Date], DESC ) )
RETURN
    IF (
        HASONEVALUE ( state[state] ),
        CALCULATE (
            SUM ( 'fact'[num] ),
            KEEPFILTERS ( 'calendar'[Date] = _latestdate )
        )
    )

 

Diff expected result: = 
VAR _t =
    CALCULATETABLE (
        SUMMARIZE ( 'fact', 'calendar'[Date] ),
        REMOVEFILTERS ( 'calendar'[Date] )
    )
VAR _latestdate =
    INDEX ( 1, _t, ORDERBY ( 'calendar'[Date], DESC ) )
RETURN
    IF (
        HASONEVALUE ( state[state] ),
        CALCULATE (
            SUM ( 'fact'[diff] ),
            KEEPFILTERS ( 'calendar'[Date] = _latestdate )
        )
    )

 



Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



shafiz_p
Super User
Super User

Hi @Lakshmi123  Try this measure:

LatestDateMeasure = 
CALCULATE(
    MAX('YourTable'[date_dt]),
    ALLEXCEPT('YourTable', 'YourTable'[state])
)

 

Hope this helps!!

 

Thanks,

 

Shahariar

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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