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
Rumbles
Frequent Visitor

Obtain the last value in a column per date

Capture2.PNG

 

Hi all,

 

I have a table that, for example, tracks location throughout the day.

 

I would like to have a column indicating the last location on each particular date. How would I go about that?

 

As a bonus, it would be great to have an additional column that would show the last location say before 2am on each day.

eg. on 21/04/2018, the last location of the day was Kintbury, although it was beyond midnight, so with the above logic, it would have counted 'Savile Club'.

 

Does that make sense?

 

Rumbles

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @Rumbles,

 

Try this:

Last Location =
CALCULATE (
    LASTNONBLANK ( Location[Location], 1 ),
    FILTER (
        ALLEXCEPT ( Location, Location[Date] ),
        Location[Time]
            = CALCULATE ( MAX ( Location[Time] ), ALLEXCEPT ( Location, Location[Date] ) )
    )
)

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

1 REPLY 1
v-yulgu-msft
Employee
Employee

Hi @Rumbles,

 

Try this:

Last Location =
CALCULATE (
    LASTNONBLANK ( Location[Location], 1 ),
    FILTER (
        ALLEXCEPT ( Location, Location[Date] ),
        Location[Time]
            = CALCULATE ( MAX ( Location[Time] ), ALLEXCEPT ( Location, Location[Date] ) )
    )
)

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.