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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Raman3456
Helper II
Helper II

Select required dates from slicer selection

Hello Eveyone ,

 

I have a data customer , creation date , Revenue.

 

i want one table which if I select a creation date in my slicer ---- table data would show ( mar 5 2024 If I select .... I want to showcase table last 4 months data along with ... 

 

( 05-03-204, 04-03-2024,03-03-2024,02-03-2024,01-03-2024, 05-02-024, 04-02-2024,03-02-2024,01-02-2024 ..... till last 4 months only )

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Raman3456 ,

The Table data is shown below:

vzhouwenmsft_0-1720061613138.png

Please follow these steps:

1.Create a date table for a slicer.

 

Calendar = CALENDAR(DATE(2023,1,1),DATE(2024,12,31))

 

vzhouwenmsft_1-1720061738233.png

vzhouwenmsft_2-1720061793296.png

 

vzhouwenmsft_3-1720061815339.png

2.Use the following DAX expression to create a measure

 

MEASURE =
VAR _dateForSlicer =
    MAX ( 'Calendar'[Date] )
VAR _1MonthAgo =
    EDATE ( _dateForSlicer, -1 )
VAR _2MonthAgo =
    EDATE ( _dateForSlicer, -2 )
VAR _3MonthAgo =
    EDATE ( _dateForSlicer, -3 )
VAR _table1 =
    CALENDAR (
        DATE ( YEAR ( _dateForSlicer ), MONTH ( _dateForSlicer ), 1 ),
        _dateForSlicer
    )
VAR _table2 =
    CALENDAR (
        DATE ( YEAR ( _1MonthAgo ), MONTH ( _1MonthAgo ), 1 ),
        DATE ( YEAR ( _1MonthAgo ), MONTH ( _1MonthAgo ), DAY ( _dateForSlicer ) )
    )
VAR _table3 =
    CALENDAR (
        DATE ( YEAR ( _2MonthAgo ), MONTH ( _2MonthAgo ), 1 ),
        DATE ( YEAR ( _2MonthAgo ), MONTH ( _2MonthAgo ), DAY ( _dateForSlicer ) )
    )
VAR _table4 =
    CALENDAR (
        DATE ( YEAR ( _3MonthAgo ), MONTH ( _3MonthAgo ), 1 ),
        DATE ( YEAR ( _3MonthAgo ), MONTH ( _3MonthAgo ), DAY ( _dateForSlicer ) )
    )
VAR _dateTable =
    UNION ( _table1, _table2, _table3, _table4 )
RETURN
    SUMX ( FILTER ( 'Table', 'Table'[Creation Date] IN _dateTable ), [Revenue] )

 

3.Final output

vzhouwenmsft_4-1720061924932.png

vzhouwenmsft_5-1720061942356.png

 

Best Regards,
Wenbin Zhou
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
Anonymous
Not applicable

Hi @Raman3456 ,

The Table data is shown below:

vzhouwenmsft_0-1720061613138.png

Please follow these steps:

1.Create a date table for a slicer.

 

Calendar = CALENDAR(DATE(2023,1,1),DATE(2024,12,31))

 

vzhouwenmsft_1-1720061738233.png

vzhouwenmsft_2-1720061793296.png

 

vzhouwenmsft_3-1720061815339.png

2.Use the following DAX expression to create a measure

 

MEASURE =
VAR _dateForSlicer =
    MAX ( 'Calendar'[Date] )
VAR _1MonthAgo =
    EDATE ( _dateForSlicer, -1 )
VAR _2MonthAgo =
    EDATE ( _dateForSlicer, -2 )
VAR _3MonthAgo =
    EDATE ( _dateForSlicer, -3 )
VAR _table1 =
    CALENDAR (
        DATE ( YEAR ( _dateForSlicer ), MONTH ( _dateForSlicer ), 1 ),
        _dateForSlicer
    )
VAR _table2 =
    CALENDAR (
        DATE ( YEAR ( _1MonthAgo ), MONTH ( _1MonthAgo ), 1 ),
        DATE ( YEAR ( _1MonthAgo ), MONTH ( _1MonthAgo ), DAY ( _dateForSlicer ) )
    )
VAR _table3 =
    CALENDAR (
        DATE ( YEAR ( _2MonthAgo ), MONTH ( _2MonthAgo ), 1 ),
        DATE ( YEAR ( _2MonthAgo ), MONTH ( _2MonthAgo ), DAY ( _dateForSlicer ) )
    )
VAR _table4 =
    CALENDAR (
        DATE ( YEAR ( _3MonthAgo ), MONTH ( _3MonthAgo ), 1 ),
        DATE ( YEAR ( _3MonthAgo ), MONTH ( _3MonthAgo ), DAY ( _dateForSlicer ) )
    )
VAR _dateTable =
    UNION ( _table1, _table2, _table3, _table4 )
RETURN
    SUMX ( FILTER ( 'Table', 'Table'[Creation Date] IN _dateTable ), [Revenue] )

 

3.Final output

vzhouwenmsft_4-1720061924932.png

vzhouwenmsft_5-1720061942356.png

 

Best Regards,
Wenbin Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.