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
DYY94
Helper I
Helper I

How get a list of date from an expression

Hello community,

 

I am trying to find a way how to get the list of date when i do this expression with DAX

 

For exemple : 16/11/2025 - 3 

 

The output should be like this (the last 3 Dates): 

16/11/2024

16/11/2023

16/11/2022

 

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @DYY94 ,

Please try below steps:

1. below is my test table

create with dax formula

Table = CALENDAR(DATE(2022,1,1),DATE(2025,12,31))

vbinbinyumsft_0-1668668617909.png

2. create a measure with below dax formula and add a card visual with this measure

Measure =
VAR str = "2025/11/16-3"
VAR _date =
    FORMAT ( LEFT ( str, 10 ), "yyyy/mm/dd" )
VAR _num =
    RIGHT ( str, 1 )
VAR _cal =
    MID ( str, 11, 1 )
VAR tmp =
    FILTER (
        ALL ( 'Table' ),
        YEAR ( [Date] )
            >= YEAR ( _date ) - _num
            && YEAR ( [Date] ) < YEAR ( _date )
            && MONTH ( [Date] ) = MONTH ( _date )
            && DAY ( [Date] ) = DAY ( _date )
    )
VAR _a =
    CONCATENATEX ( tmp, [Date], "
" )
RETURN
    SWITCH ( TRUE (), _cal = "-", _a )

vbinbinyumsft_1-1668668735684.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
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

4 REPLIES 4
v-binbinyu-msft
Community Support
Community Support

Hi @DYY94 ,

Please try below steps:

1. below is my test table

create with dax formula

Table = CALENDAR(DATE(2022,1,1),DATE(2025,12,31))

vbinbinyumsft_0-1668668617909.png

2. create a measure with below dax formula and add a card visual with this measure

Measure =
VAR str = "2025/11/16-3"
VAR _date =
    FORMAT ( LEFT ( str, 10 ), "yyyy/mm/dd" )
VAR _num =
    RIGHT ( str, 1 )
VAR _cal =
    MID ( str, 11, 1 )
VAR tmp =
    FILTER (
        ALL ( 'Table' ),
        YEAR ( [Date] )
            >= YEAR ( _date ) - _num
            && YEAR ( [Date] ) < YEAR ( _date )
            && MONTH ( [Date] ) = MONTH ( _date )
            && DAY ( [Date] ) = DAY ( _date )
    )
VAR _a =
    CONCATENATEX ( tmp, [Date], "
" )
RETURN
    SWITCH ( TRUE (), _cal = "-", _a )

vbinbinyumsft_1-1668668735684.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks @v-binbinyu-msft  it's great !

 

Is it possible to duplicate rows by Code_ISIN for each dates ? 

- Each date in a row with the same Code_ISIN. 

 

Check below screenshot. 

Thank a lot ! 

 

Capture2.PNG

Hi @v-binbinyu-msft ,

 

Thanks for the solution it's really hepful as i need it.

 

I need just some edit about the Output if it possible. 

1- for exemple when i do this :

  •      10/04/2024 - 1 (Output)=> 10/04/2023

     and also for this condition: 

  •      10/04/2023 - 0 (Output)=> 10/04/2023 ( stay the same) 
  •      10/04/2026 - 3 (Output)=> 10/04/2025 - 10/04/2024 - 10/04/2023

-And is it possible to store the dates in a list or table because i'm gonna use it later in other formula. 

 

You can check below screenshot inluding the the input column and you the output with your solution. 

 

  • [maturite] - MR/365] = Ouput 

 

Capture.PNG

 

Thanks again for you help 🙂

ThomasWeppler
Skilled Sharer
Skilled Sharer

It sounds like you want to copare specifik dates from diffrent years.

If this is the case then this is the way I would do it.

Add a calender table.
connect it to the table you want to filter on.

add the dates in the x-axis
Legend should be years.
This way you will be able to see result from the diffrent years right next to each other.

 

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.