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

Return value from Date table based on current date

This seems so simple but its not working.

I have a MasterDate table and I am trying to find the first Date for the Incentive Quarter.

 

bignadad_0-1708197076902.png

The incentive quarter is based on today's date which would be 3 in this case.

So i need to find the min date where the incentive quarter and year equals todays date.

In this case it would be 12/1/2023

bignadad_1-1708197190856.png

 

I tried this measure to retreive the current incentive quarter but it wont work. it's blank

thisQtr = CALCULATE(MAX(MasterDate[Incentive Quarter]),MasterDate[Dates]=TODAY())
bignadad_2-1708197243153.png

This is the measure I tried but it retrieves the fist date in the date table

First Day Qtr =
var thisQtr = CALCULATE(MAX(MasterDate[Incentive Quarter]),MasterDate[Dates]=TODAY())
RETURN
CALCULATE(MIN(MasterDate[Dates].[Date]),MasterDate[Incentive Quarter]=thisQtr,MasterDate[Year]=YEAR(TODAY()))
1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

It seems like this one should work. Is there maybe a filter on the dates tables somewhere else?  Maybe try this.

 

thisQtr =
CALCULATE (
    MAX ( MasterDate[Incentive Quarter] ),
    ALL ( MasterDate ),
    MasterDate[Dates] = TODAY ()
)

 

Or maybe your MasterDate table does not include today meaning it is cutting off before today?

 

I tested something similar in a sample file and got what I would expect:

 

Today Month Year =
CALCULATE ( 
    MAX ( Dates[Mth-Year] ),
    ALL ( Dates ),
    Dates[Date] = TODAY ()
)

 

jdbuchanan71_0-1708200965411.png

 

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Share some sample data to work with (in a format that can be pasted in an MS Excel file) and show the expected result.


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

It seems like this one should work. Is there maybe a filter on the dates tables somewhere else?  Maybe try this.

 

thisQtr =
CALCULATE (
    MAX ( MasterDate[Incentive Quarter] ),
    ALL ( MasterDate ),
    MasterDate[Dates] = TODAY ()
)

 

Or maybe your MasterDate table does not include today meaning it is cutting off before today?

 

I tested something similar in a sample file and got what I would expect:

 

Today Month Year =
CALCULATE ( 
    MAX ( Dates[Mth-Year] ),
    ALL ( Dates ),
    Dates[Date] = TODAY ()
)

 

jdbuchanan71_0-1708200965411.png

 

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.