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
antlufc
Frequent Visitor

Different Dates based upon 2 different columns

The table below shows MQLs by latest date and latest event flag. 

I would like to show the volume of MQLs that are Not Accepted or Achived using the MQLs - latest date. 

 

So in my below examples i would like Key 7442051 to be counted and use the date 22/9/2023 and 7085123 to be counted and use 1/9/2023. It may also occur where they are on the same date and some instances where Not Accpted and Archived are either not the latest event or may not appear at all. 

I can not add a column or amend the power query so i would like to solve this problem using DAX. 


(Column Names as per below, this is only in relation to the table below

Column 1 = Stage Name
Column 2 = MQLs latest Date

Column 3 = latest event flag
Colimn 4 = date

Column 5 = Key)



New1022/09/20237442051
Working0022/09/2023 7442051
Working0026/09/2023 7442051
Working0027/09/2023 7442051
Not Accepted0127/09/2023 7442051
New0009/08/2023 7085123
New1001/09/2023 7085123
Working0001/09/2023 7085123
Working0005/09/2023 7085123
Archived0105/09/2023 7085123

 

10 REPLIES 10
antlufc
Frequent Visitor

@Greg_Deckler sorry forgot to mention stage name is in a different table to latest evcent flag however they linked via a relationship 

@antlufc What is the relationship? As in, what forms the relationship?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  - date key based on event date from the fact table to date key in the date dimension.  The event date could be associated with events prior and post the MQL latest date

@antlufc I'm not quite following this. So you have a Date dimension and that includes what the Stage is for each Key based on which Date? Maybe post a picture of your data model or at least the relevant tables. I'm not understanding how you are arriving at the correct Stage for a specified Key and Date.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

date dimension - which provides the date linked to fact events via date key

fact events table -  which provides the MQL latest date, key and date key which links to date dimension based on the date an event happened and dim events via the key


dim events -  which contains the stage name which is linked to fact events via the key. 

@antlufc So the dim events table also has a date so you know what stage a key was in on a specific date?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler - no dim events only has the stage name. 

The date where the specific event has happened is in fact events. 

antlufc
Frequent Visitor

@Greg_Deckler - i need to take into account if the MQL is Archived / Not Accpeted and take into account the date of the latest MQL. 

Would be - provide the count of MQLs latest date where the latest event flag = 1 and the stage name = Not Accpted or Archived. 

@antlufc OK, how about this? PBIX attached below signature.

Measure = 
  VAR __Statuses = { "Archived", "Not Accepted" }
  VAR __LatestStatus = MAXX( FILTER( 'Table', [latest event flag] = 1 ), [Stage Name] )
  VAR __MaxDate = MAXX( FILTER('Table', [MQLs latest Date] = 1), [date] )
  VAR __Result = IF( __LatestStatus IN __Statuses, __MaxDate, BLANK() )
RETURN
  __Result

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

@antlufc Not sure I fully understand but perhaps something like:

Measure =
  VAR __Table = FILTER('Table', [MQLs latest Date] = 1)
  VAR __MaxDate = MAXX( __Table, [date] )
RETURN
  __MaxDate

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.