cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gooranga1
Impactful Individual
Impactful Individual

Finding first event

Hi,

 

I am having trouble with what I thought was a really easy measure.

 

I hav a DimDate dimension and FactEvents fact table joined on date key(not date). I also have a DimLocations Dimension join to the FactEvents.

FactEvents doesn't have a date in it just the key. I am trying to find the first ever event for each location. I can find the first date_key ok but I am having a devil of a job of getting the actual first date using the DimDate dimension. I want the first event regardless of any date filters applied.

 

First Event =
CALCULATE (
    MIN ( FactEvents[event_date_key] ),
    ALL ( FactEvents ),
    FILTER (
        DimLocationDoorLock,
        DimLocationDoorLock[LocationDoorLockKey]
            MAX ( DimLocationDoorLock[LocationDoorLockKey] )
    )
)

 

works fine but I cannot get to a min of DimDate date without getting the date onto the fact table. Is there a cunning way around this?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@gooranga1 , Try like

 

First Event =
CALCULATE (
MINX(all(FactEvents), related('Date'[Date]))
FILTER (
DimLocationDoorLock,
DimLocationDoorLock[LocationDoorLockKey]
= MAX ( DimLocationDoorLock[LocationDoorLockKey] )
)
)

 

 

Two dimesion do not join, so we have to go via fact



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

View solution in original post

2 REPLIES 2
gooranga1
Impactful Individual
Impactful Individual

hi @amitchandak yes thanks I was floundering about with something similar but it still doesn't seem to filter on the location bit and gives one date for all. So added the measure above. I do have the date field added now but I would like to know how to do it without as well.

 

measure brings back all datesmeasure brings back all dates

First Client Event 1 =
CALCULATE (
MINX ( ALL ( FactEvents ), RELATED ( 'DimDate'[Date] ) ),
FILTER (
DimLocationDoorLock,
DimLocationDoorLock[LocationDoorLockKey]
= MAX ( DimLocationDoorLock[LocationDoorLockKey] )
)
)

 

 

**********************************************************

**********************************************************

Added Allselected and it has done the trick! thanks

 

First Client Event 1 =
CALCULATE (
MINX ( ALLSELECTED ( FactEvents ), RELATED ( 'DimDate'[Date] ) ),
FILTER (
(DimLocationDoorLock),
DimLocationDoorLock[LocationDoorLockKey]
= MAX ( DimLocationDoorLock[LocationDoorLockKey] )
)
)

 

 

 

amitchandak
Super User
Super User

@gooranga1 , Try like

 

First Event =
CALCULATE (
MINX(all(FactEvents), related('Date'[Date]))
FILTER (
DimLocationDoorLock,
DimLocationDoorLock[LocationDoorLockKey]
= MAX ( DimLocationDoorLock[LocationDoorLockKey] )
)
)

 

 

Two dimesion do not join, so we have to go via fact



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors