Forum Discussion

jmetf150's avatar
jmetf150
Helper I
2 years ago
Solved

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 
  • 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
  • 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.

7 Replies

  • 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?

    • Greg_Deckler's avatar
      Greg_Deckler
      Community Champion

      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
  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    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
    • jmetf150's avatar
      jmetf150
      Helper I

      Greg_Deckler  To simplify this for me, how would this look if you only had 2 columns.  PO & Confrimation type.

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion

        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.