Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Dax help with conversion

Hi community,    Can you please help me writing following in measure and Column.    I have product  two products in data ( F and NF) . I  want create measure and column where I could identify cus...
  • v-cazheng-msft's avatar
    4 years ago

    Hi Anonymous 

     

    Please try this Measure or Calculated column.

    1 Measure

    IsNF -> F =

    VAR PreDate =

        CALCULATE (

            MAX ( 'Table'[Date] ),

            FILTER (

                ALL ( 'Table' ),

                'Table'[ID] = MAX ( 'Table'[ID] )

                    && 'Table'[Date] < MAX ( 'Table'[Date] )

                    && [Product F Acquired] = "N"

            )

        )

    RETURN

        IF (

            ISBLANK(PreDate),

            "",

            IF ( DATEDIFF ( PreDate, MAX ( 'Table'[Date] ), DAY ) < 365, "Y", "N" )

        )

     

     

    2 Calculated column

    IsNF -> F_Col =

    VAR PreDate =

        CALCULATE (

            MAX ( 'Table'[Date] ),

            FILTER (

                ALL ( 'Table' ),

                'Table'[ID] = EARLIER ( 'Table'[ID] )

                    && 'Table'[Date] < EARLIER ( 'Table'[Date] )

                    && [Product F Acquired] = "N"

            )

        )

    RETURN

        IF (

            ISBLANK ( PreDate ),

            "",

            IF ( DATEDIFF ( PreDate, 'Table'[Date], DAY ) < 365, "Y", "N" )

        )

     

    Then, the result should look like this.

     

    Attached the pbix file as reference.

     

    Best Regards,

    Community Support Team _ Caiyun

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!