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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
gladies123
Helper I
Helper I

Reg: Adding Dates

Hi Team,

This is to inform you that i am having different two date one is refresh date another one is id_expiry date, if i select a date from slicer which contains refresh_date for example date is (29-06-2021) that id_expiry date should return from (01-06-2021 to 30-6-2021)=this month, and (01-07-2021 to 31-07-2021)=next month, (01-06-2021 to 31-07-2021)=60 days and (01-06-2021 to 31-08-2021)=90 days . Kindly help me on this dax.

 

Thanks,

Gladis

 

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

Hi @gladies123 ,

 

First create a calendar table as the slicer;

Then create 4 measures as below:

id_expiry date(this month) =
VAR _startdate =
    STARTOFMONTH ( 'Table 2'[Date] )
VAR _enddate =
    ENDOFMONTH ( 'Table 2'[Date] )
RETURN
    IF (
        SELECTEDVALUE ( 'Table 2'[Date] ) IN FILTERS ( 'Table'[refresh date] ),
        FORMAT ( _startdate, "dd-mm-yyyy" ) & " to "
            & FORMAT ( _enddate, "dd-mm-yyyy" )
    )
id_expiry date(next month) =
VAR _startdate =
    DATEADD ( STARTOFMONTH ( 'Table 2'[Date] ), 1, MONTH )
VAR _enddate =
    DATEADD ( ENDOFMONTH ( 'Table 2'[Date] ), 1, MONTH )
RETURN
    IF (
        SELECTEDVALUE ( 'Table 2'[Date] ) IN FILTERS ( 'Table'[refresh date] ),
        FORMAT ( _startdate, "dd-mm-yyyy" ) & " to "
            & FORMAT ( _enddate, "dd-mm-yyyy" )
    )
id_expiry date(60 days) =
VAR _startdate =
    STARTOFMONTH ( 'Table 2'[Date] )
VAR _enddate =
    DATEADD ( ENDOFMONTH ( 'Table 2'[Date] ), 1, MONTH )
RETURN
    IF (
        SELECTEDVALUE ( 'Table 2'[Date] ) IN FILTERS ( 'Table'[refresh date] ),
        FORMAT ( _startdate, "dd-mm-yyyy" ) & " to "
            & FORMAT ( _enddate, "dd-mm-yyyy" )
    )
id_expiry date(90 days) =
VAR _startdate =
    STARTOFMONTH ( 'Table 2'[Date] )
VAR _enddate =
    DATEADD ( ENDOFMONTH ( 'Table 2'[Date] ), 2, MONTH )
RETURN
    IF (
        SELECTEDVALUE ( 'Table 2'[Date] ) IN FILTERS ( 'Table'[refresh date] ),
        FORMAT ( _startdate, "dd-mm-yyyy" ) & " to "
            & FORMAT ( _enddate, "dd-mm-yyyy" )
    )

And you will see:

vkellymsft_0-1630915364845.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi @gladies123 ,

 

First create a calendar table as the slicer;

Then create 4 measures as below:

id_expiry date(this month) =
VAR _startdate =
    STARTOFMONTH ( 'Table 2'[Date] )
VAR _enddate =
    ENDOFMONTH ( 'Table 2'[Date] )
RETURN
    IF (
        SELECTEDVALUE ( 'Table 2'[Date] ) IN FILTERS ( 'Table'[refresh date] ),
        FORMAT ( _startdate, "dd-mm-yyyy" ) & " to "
            & FORMAT ( _enddate, "dd-mm-yyyy" )
    )
id_expiry date(next month) =
VAR _startdate =
    DATEADD ( STARTOFMONTH ( 'Table 2'[Date] ), 1, MONTH )
VAR _enddate =
    DATEADD ( ENDOFMONTH ( 'Table 2'[Date] ), 1, MONTH )
RETURN
    IF (
        SELECTEDVALUE ( 'Table 2'[Date] ) IN FILTERS ( 'Table'[refresh date] ),
        FORMAT ( _startdate, "dd-mm-yyyy" ) & " to "
            & FORMAT ( _enddate, "dd-mm-yyyy" )
    )
id_expiry date(60 days) =
VAR _startdate =
    STARTOFMONTH ( 'Table 2'[Date] )
VAR _enddate =
    DATEADD ( ENDOFMONTH ( 'Table 2'[Date] ), 1, MONTH )
RETURN
    IF (
        SELECTEDVALUE ( 'Table 2'[Date] ) IN FILTERS ( 'Table'[refresh date] ),
        FORMAT ( _startdate, "dd-mm-yyyy" ) & " to "
            & FORMAT ( _enddate, "dd-mm-yyyy" )
    )
id_expiry date(90 days) =
VAR _startdate =
    STARTOFMONTH ( 'Table 2'[Date] )
VAR _enddate =
    DATEADD ( ENDOFMONTH ( 'Table 2'[Date] ), 2, MONTH )
RETURN
    IF (
        SELECTEDVALUE ( 'Table 2'[Date] ) IN FILTERS ( 'Table'[refresh date] ),
        FORMAT ( _startdate, "dd-mm-yyyy" ) & " to "
            & FORMAT ( _enddate, "dd-mm-yyyy" )
    )

And you will see:

vkellymsft_0-1630915364845.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

amitchandak
Super User
Super User

@gladies123 ,The information you have provided is not making the problem clear to me. Can you please explain with an example.

Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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