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
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
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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.