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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
CarMechanic
New Member

Need Help writing a DAX Formula that returns distinct values based on max date

Hello everyone, 
i need your help in writing a DAX Formula that returns distinct values for a row, based on max date that is smaller or equal to the value chosen in a slicer.


So i have a DataTable which is being loaded every day with new rows that have been updated. As you can see every change in the customer data is updated, by adding a new row with new loadtime.
Example:

CustomerNamePostal CodeLoadtime
XXXJohn555 55522.02.2023
XXXJohn666 66620.02.2023
YYYElisabeth444 44422.02.2023
YYYEmma444 44415.02.2023
ZZZJules111 11111.02.2023


So if i choose a DATE with a SLICER : 22.02.2023 

I want to get is a table that looks like this:

CustomerNamePostal CodeLoadtime
XXXJohn555 55522.02.2023
YYYElisabeth444 44422.02.2023
ZZZJules111 11111.02.2023


but if i change the slicer value to : 11.02.2023
i want a table to look like this:

CustomerNamePostal COdeLoadtime
ZZZJules111 11111.02.2023


I have tried different formulas but was unfortunately not successful. Would apperciate your help. 
Best Regards

5 REPLIES 5
tamerj1
Super User
Super User

Hi @CarMechanic 

the date slicer is coming from a dimDate table?

yes

@CarMechanic 

Try by placing the following measure in the filter pane of the table visual and select "is" (1) then apply the filter

FilterMeasure =
INT (
MAX ( DataTable[Loadtime] )
= CALCULATE (
MAX ( DataTable[Loadtime] ),
ALLEXCEPT ( DataTable, DataTable[Name] ),
'Date'[Date] <= MAX ( 'Date'[Date] )
)
)

FreemanZ
Super User
Super User

hi @CarMechanic 

try to plot a table visual with Customer and Name columns and two measures like:
 
LoadtimeLast =
MAX(DataTable[Loadtime])
 
PostalCodeLast =
MAXX(
    FILTER(
        DataTable,
        DataTable[Loadtime]=[LoadtimeLast]
    ),
    DataTable[Postal Code]
)

hello @FreemanZ ,
thanks for the fast response. 
Unfortunately this solution doesnt cover all the changes that can happen in a row. The tables i have posted are only examples. The real data rows consist of 30 columns with different attributes. Whenever one of the attributes changes, a new row with new loadtime will be added for a customer. So the solution must be more flexible than that. But thanks 🙂

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.