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

10 last days in Date Table

Hello everybody,

 

I hope you all are very good!!!

 

I have a Table with dates, and I want to filter only the last ten days... So I need a filter in my report that shows "Last ten days". What I was doing is a new column in the table with the next formula:

 

Loaded Date 5 = IF(
                    (MAX('NexThing Files'[dataDate]) in {'NexThing Files'[dataDate],'NexThing Files'[dataDate]-1,'NexThing Files'[dataDate]-2,'NexThing Files'[dataDate]-3,'NexThing Files'[dataDate]-4,'NexThing Files'[dataDate]-5,'NexThing Files'[dataDate]-6,'NexThing Files'[dataDate]-7,'NexThing Files'[dataDate]-8,'NexThing Files'[dataDate]-9,'NexThing Files'[dataDate]-10}),
                    "Last 10 Days",
                    format('NexThing Files'[Loaded Date],"dd/mm/yyyy")
                    )
 
But it does only function properly for the first date:Chema_Ortega_Ga_0-1731059880260.png

The formula should put "Last 10 days" in all the yellow dates (10 dates), and in the other dates it should put the date.

 

Any workaround for this?

 

Thanks a lot. Best regards,

 

Chema Ortega

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Chema_Ortega_Ga 

A simple formula as below should work

Date Category = 
IF (
    'NexThing Files'[Loaded Date]
        >= MAX ( 'NexThing Files'[Loaded Date] ) - 9,
    "Last 10 days",
    FORMAT ( 'NexThing Files'[Loaded Date], "dd/mm/yyyy" )
)

danextian_0-1731061692260.png

Note. if you intend to use the calculated column in a slicer, the values will be sorted alphabetically so the dates will ot be in the correct order. Add another calc column to sort it by.

Date Category Sort = 
IF (
    'NexThing Files'[Loaded Date]
        >= MAX ( 'NexThing Files'[Loaded Date] ) - 9,
    1,
    'NexThing Files'[Loaded Date]
)

danextian_3-1731062117719.png

 

 

 

Date Category Sort = 
IF (
    'NexThing Files'[Loaded Date]
        >= MAX ( 'NexThing Files'[Loaded Date] ) - 9,
    100000,
    'NexThing Files'[Loaded Date]
)

 

danextian_4-1731062234881.png

 

 

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

5 REPLIES 5
gvlado
Advocate III
Advocate III

Try to use filter for this visual or page or all pages on filter pane

gvlado_0-1731071029376.png

 

danextian
Super User
Super User

Hi @Chema_Ortega_Ga 

A simple formula as below should work

Date Category = 
IF (
    'NexThing Files'[Loaded Date]
        >= MAX ( 'NexThing Files'[Loaded Date] ) - 9,
    "Last 10 days",
    FORMAT ( 'NexThing Files'[Loaded Date], "dd/mm/yyyy" )
)

danextian_0-1731061692260.png

Note. if you intend to use the calculated column in a slicer, the values will be sorted alphabetically so the dates will ot be in the correct order. Add another calc column to sort it by.

Date Category Sort = 
IF (
    'NexThing Files'[Loaded Date]
        >= MAX ( 'NexThing Files'[Loaded Date] ) - 9,
    1,
    'NexThing Files'[Loaded Date]
)

danextian_3-1731062117719.png

 

 

 

Date Category Sort = 
IF (
    'NexThing Files'[Loaded Date]
        >= MAX ( 'NexThing Files'[Loaded Date] ) - 9,
    100000,
    'NexThing Files'[Loaded Date]
)

 

danextian_4-1731062234881.png

 

 

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi Danextian... Thanks a lot! Thats what I needed! That is the solution... that's GREAT! Best regards

Angith_Nair
Continued Contributor
Continued Contributor

Hi @Chema_Ortega_Ga 

 

Use the below dax:

Loaded Date 5 = 
IF(
    'NexThing Files'[dataDate] >= (MAX('NexThing Files'[dataDate]) - 9) 
        && 'NexThing Files'[dataDate] <= MAX('NexThing Files'[dataDate]),
    "Last 10 Days",
    FORMAT('NexThing Files'[dataDate], "dd/mm/yyyy")
)

Hi Angith,

 

Thanks a lot! That also works great! Thanks a lot. Best regard!

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.