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

Display latest month in card when data exists in visual

I have a the following visual that is correct for the current year:

 

CMccown_0-1659655732993.png

 

However when I choose 2021 for year the month card does not display December:

CMccown_1-1659655849273.png

 

I realize that the measure calculating the last month needs to be filtered for year as well but I'm not sure what I need to include in order to do that.

 

The measure I created for the month is as follows:  MaxMonth = (Format(Date(1, Month(MAX('DailyWeather'[Date])),1),"MMMM"))

 

Any help would be greatly appreciated!

1 ACCEPTED SOLUTION

@amitchandak - thank you for providing these options! The solution to my particular problem was solved with a much simpler solution. I created a measure that found the last date for the year subject to the filter and formatted it to reflect the month in text: 

 

Latest_Month = (Format(Date(1, Month(Lastdate(DailyWeather[Date])),1),"MMMM"))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@CMccown , In below you have few option var

 

var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , eomonth(today(),0) )

 

var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , maxx(allselected(Table), Table[Date])  )

 

replace var _max as per need

 

MTD =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1)+1 ,
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

This Month =
var _max = eomonth(if(isfiltered('Date'),MAX( 'Date'[Date]) , today()),0)
var _min = eomonth(_max,-1)+1 ,
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

Last Month =
var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _max = eomonth(_max1,-1)
var _min = eomonth(_max1,-2)+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

@amitchandak - thank you for providing these options! The solution to my particular problem was solved with a much simpler solution. I created a measure that found the last date for the year subject to the filter and formatted it to reflect the month in text: 

 

Latest_Month = (Format(Date(1, Month(Lastdate(DailyWeather[Date])),1),"MMMM"))

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.