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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
murphm6
Helper II
Helper II

Dynamically change card visual based on date selection

Hey all,

 

I have a card visual which displays the 'Days Left in Month'. This is a measure that just takes the date difference between today and EOMONTH. 

 

My end-user wants to be able to see what numbers for next month look like. When they filter for Next Month in the 'Date Selection' filter, the 'Days left in Month' visual still only show the date diff between today and end of current month.

 

How can I set it up so that this visual will dynamically change? If they're looking at current month, it will take the date diff between today and end of month. And if they're looking at next month, it will just calculate total days in the month? I think a SWITCH() function will be used here, but not sure how to implement this.

 

 

murphm6_0-1668696518019.png

 

1 ACCEPTED SOLUTION

@murphm6 ,

You are close.   Please try this:

DaysLeftinMonth = SWITCH(
                      TRUE(),
                      [MaxSelectedDate] = EOMONTH( TODAY(), 0 ), DATEDIFF( TODAY(), (EOMONTH( TODAY(), 0 )), DAY ),
                      DAY(EOMONTH(TODAY(), 1) ))

Where
MaxSelectedDate = MAX(DIM_Date[Date] )

My quick test shows it works, but may need tweaking depending on how many Months in the future the user selects.

Hope you can get this to work for you.

Regards,

View solution in original post

2 REPLIES 2
murphm6
Helper II
Helper II

Switch(SELECTEDVALUE('Calendar'[Date]), MONTH(TODAY()), DATEDIFF(TODAY(), EOMONTH(TODAY(), 0), DAY), MONTH(TODAY()+1), Day(EOMONTH(TODAY() + 1,0)))

 

Tried using this, but doesn't seem to be working correctly. Anyone have any suggestions?

@murphm6 ,

You are close.   Please try this:

DaysLeftinMonth = SWITCH(
                      TRUE(),
                      [MaxSelectedDate] = EOMONTH( TODAY(), 0 ), DATEDIFF( TODAY(), (EOMONTH( TODAY(), 0 )), DAY ),
                      DAY(EOMONTH(TODAY(), 1) ))

Where
MaxSelectedDate = MAX(DIM_Date[Date] )

My quick test shows it works, but may need tweaking depending on how many Months in the future the user selects.

Hope you can get this to work for you.

Regards,

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Kudoed Authors