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
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') ) ) )

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.