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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
LMSF
New Member

FirstDate/LastDate not being applied to current context

I have an issue that might be down to my own lack of understanding of how FirstDate/LastDate work. As per the Microsoft Docs it should apply context and I assumed bring back a dynamic LastDate 

MS Docs Definition - "Returns the last date in the current context for the specified column of dates."

 

I have a data model with a fact table called AuditResults storing AuditIDs which is linked to an Audit dimension table holding the date of these audits. There is a second dimension table linked on Depot IDs which maps the sites audits were comleted at and contains site names and region names the sites live in. 

 

I'm simply trying to list Audit IDs in column 1 of a Table visual and the first date of the audits in the second column. But it always brings back the first date of ALL the AuditIDs. I was also trying to list the first date by Depot but it gives the same error. 

 

Below is my data model and an example of the error. I'm pulling in the AuditID from Fact Audit Results and a measure which is the following line of code...

 

DateMeasure = FIRSTDATE('Dim Audits'[AuditDate])

 

Any help is appreciated!LastDate Error.PNG

 

Data Model.PNG

 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @LMSF ,

Normally, FIRSTDATE will return the correct value, I think your error may be related to the relationship between the tables.

You can modify the formula like this, it will not be affected by the relationship..

DateMeasure =
MINX (
    FILTER ( 'Dim Audits', 'Dim Audits'[AuditID] = MAX ( 'AuditResults'[AuditID] ) ),
    'Dim Audits'[AuditDate]
)

vkalyjmsft_0-1638958506022.png

 

I attach my sample below for reference.

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @LMSF ,

Normally, FIRSTDATE will return the correct value, I think your error may be related to the relationship between the tables.

You can modify the formula like this, it will not be affected by the relationship..

DateMeasure =
MINX (
    FILTER ( 'Dim Audits', 'Dim Audits'[AuditID] = MAX ( 'AuditResults'[AuditID] ) ),
    'Dim Audits'[AuditDate]
)

vkalyjmsft_0-1638958506022.png

 

I attach my sample below for reference.

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@LMSF , Depot is not joined Audit Dim. So we need force fact

 

DateMeasure = calculate(FIRSTDATE('Dim Audits'[AuditDate]), filter(Filter('Fact Audit Result', not(isblank('Fact Audit Result') ) ) )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.