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
danyeungw
Helper II
Helper II

How to get Report Date = Slicer Latest Selected Date

I created a measure named "Selected Date' to get the latest selected date from a slicer. The date returned corrected. See Image. I created another measure to assign "Quarter End" or "Current". See the code below.  The "Quarter End" is correct. However, all other rows had "Current". I want the rows with Report Date "3/8/2023" in this example to have "Current".  What is wrong in the code? Or is there another way to do it? Thanks.

 

 

Quarters = if(ENDOFQUARTER('Table1'[ReportDate].[Date])= 'Table1'[ReportDate],"Quarter End",if('Table1'[ReportDate].[Date] = [Selected Date],"Current","")) 

 

Selected Date = LASTDATE('Table1'[ReportDate])

 

danyeungw_0-1678914073084.png

 

4 REPLIES 4
danyeungw
Helper II
Helper II

I think I know why all rows are Current, but don't know how to fix it. I am thinking if I can get the constant from "Selected Date", it may work. It is 3/4/2023 in this example.
I don't think I can attach a file here.

 

 

 

Quarters = if(ENDOFQUARTER('Table1'[ReportDate].[Date])= 'Table1'[ReportDate],"Quarter End",if('Table1'[ReportDate].[Date] = [Selected Date],"Current",""))

Selected Date = LASTDATE('Table1'[ReportDate])

SelectedDate = FORMAT([Selected Date],"MM/DD/yyyy")

 

 

danyeungw_3-1678997884377.png

 

 

 

Ashish_Mathur
Super User
Super User

Hi,

Could you share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ahmedx
Super User
Super User

write like this:

Quarters=
VAR = _MaxSelectedDate = max('Table1'[ReportDate])
RETURN
Quarters = if(ENDOFQUARTER('Table1'[ReportDate].[Date])= 'Table1'[ReportDate],
 "Quarter End",if('Table1'[ReportDate].[Date] = _MaxSelectedDate,"Current","")) 

Thanks @Ahmedx , I got an error "Unexpected expression =" on VAR =. I modified it to the followings. All rows except the "Quarter End" had "Current".

Quarters = if(ENDOFQUARTER('Table1'[ReportDate].[Date])= 'Table1'[ReportDate],
 "Quarter End",if('Table1'[ReportDate].[Date] = max('Table1'[ReportDate]),"Current","")) 

OR

Quarters = if(ENDOFQUARTER('Table1'[ReportDate].[Date])= 'Table1'[ReportDate],
"Quarter End",if('Table1'[ReportDate].[Date] = LASTDATE('Table1'[ReportDate]),"Current",""))

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.

Top Solution Authors