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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jmetf150
Helper I
Helper I

Only Display Latest Sequence

Goodday - I am looking for the DAX code/formula I can use to do the following.  I have a list of Open PO numbers.  Each open PO can have up to 9 different confirmation types.  Each confirmation type results in a seperate line and I only want to show the PO line with the latest confirmation. 

 

The different confirmations are below in sequence:

blank or null = not confirmed yet

AB

P2

E1

E2

E3

E4

E5

SN

 

Example of my data:

 

POOrd QtyConfirmation TypeConfirmation SeqConfirmation Date
45012310AB26/22/24
45012310P237/10/24
45012310E149/5/24
45012310E2510/31/24
45012310E3611/2/24
45012310E4711/30/24
45012310E5812/1/24
45012310SN912/25/25
45012310 1 
2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

@jmetf150 You can use a Complex Selector for this. The Complex Selector - Microsoft Fabric Community

Probably something like:

Measure =
  VAR __PO = MAX('Table'[PO])
  VAR __CurrentDate = MAX('Table'[Confirmation Date])
  VAR __MaxDate = MAXX( FILTER( ALL('Table'), [PO] = __PO ), [Confirmation Date])
  VAR __Result = IF( __CurrentDate = __MaxDate, 1, 0 )
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...

View solution in original post

@jmetf150 No, because they don't alphabetically sort correctly. So if you had AB, P2 and E1 and got the max, it would return P2. You could create a calculated column that assigned a number such as a SWITCH statement that assigned 1 to AB, 2 to P2, etc. and that should work in lieu of a 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...

View solution in original post

7 REPLIES 7
jmetf150
Helper I
Helper I

@Greg_Deckler forgot I already had a column that told me the sequence number for that line so just modified the "date" to the "confirmation sequence number" and filtered to only show me "1" and it worked. 

 

Now, how would I apply that meansure to a card?

@jmetf150 Well, that's a bit tricky TBH as I am not sure what you are trying to display in that card. But, if you have that Measure, you could do this:

Card Measure = 
  VAR __Table = ADDCOLUMNS('Table', "__Measure", [Measure])
  VAR __Row = FILTER(__Table, [__Measure] = 1)
  VAR __ConfirmationType = MAXX( __Row, [Confirmation Type])
RETURN
  __ConfirmationType

@ 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

@jmetf150 You can use a Complex Selector for this. The Complex Selector - Microsoft Fabric Community

Probably something like:

Measure =
  VAR __PO = MAX('Table'[PO])
  VAR __CurrentDate = MAX('Table'[Confirmation Date])
  VAR __MaxDate = MAXX( FILTER( ALL('Table'), [PO] = __PO ), [Confirmation Date])
  VAR __Result = IF( __CurrentDate = __MaxDate, 1, 0 )
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  To simplify this for me, how would this look if you only had 2 columns.  PO & Confrimation type.

@jmetf150 Then you wouldn't have anything to define "latest" so it wouldn't work unless you added like an Index column assuming that things are actually sorted correctly.


@ 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  Can you use the confirmation sequence to define the latest?  blank/null would always be first, and SN would always be last (per the sequence defined below)

 

The different confirmations are below in sequence:

blank or null = not confirmed yet

AB

P2

E1

E2

E3

E4

E5

SN

@jmetf150 No, because they don't alphabetically sort correctly. So if you had AB, P2 and E1 and got the max, it would return P2. You could create a calculated column that assigned a number such as a SWITCH statement that assigned 1 to AB, 2 to P2, etc. and that should work in lieu of a 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...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors