Forum Discussion

leandross89's avatar
leandross89
Icon for Helper II rankHelper II
2 years ago
Solved

Help to creat a calculated column in dax

Hi dear,

I would like some help to create a calculated column. This calculated column checks if the value in the "Rule_rank" column is "Rank". If so, it verifies if there are previous records where the specified conditions (Searched = 367 and Code = A ) are met. If these conditions are met, it returns "OK"; otherwise, it returns blank.


TimestampDeviceIndexSearchedCodeRule_rankCalculated Column
21/03/2024 18:42:00A1219390AOthers 
21/03/2024 18:42:00A1219367AOthersOK
21/03/2024 18:42:00A1219391AOthers 
21/03/2024 18:43:00A1220367AOthersOK
21/03/2024 18:43:00A1220391AOthers 
21/03/2024 18:43:00A1220390AOthers 
21/03/2024 18:44:00A1221367AOthersOK
21/03/2024 18:44:00A1221391AOthers 
21/03/2024 18:44:00A1221390AOthers 
21/03/2024 18:45:00A1222  Rank 
21/03/2024 18:49:00A1223  Others 
21/03/2024 18:53:00A1224  Others 
21/03/2024 22:45:00A132812AOthers 
21/03/2024 22:46:00A132912AOthers 
21/03/2024 22:46:00A1329367AOthers 
21/03/2024 22:47:00A1330367AOthers 
21/03/2024 22:47:00A133012AOthers 
21/03/2024 22:48:00A1331367AOthers 
21/03/2024 22:48:00A133112AOthers 
21/03/2024 22:49:00A1332  Others 
21/03/2024 22:53:00A1333  Others 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi leandross89 ,

    Thanks to Ahmedx  for the reply, please allow me to provide another insight:
    1. Create a calculated column and populate the data in groups.

    Column =
    CALCULATE(MIN('Table'[Index]),FILTER(ALL('Table'),'Table'[Rule_rank] = "Rank" && 'Table'[Index] >= EARLIER('Table'[Index])) )

    2. Create a calculated column and display OK if it meets the conditions.

    Column 2 =
    IF('Table'[Index] < 'Table'[Column] && 'Table'[Searched] = 367 && 'Table'[Code] = "A" ,"OK")

    If your Current Period does not refer to this, please clarify in a follow-up reply.

     

    Best Regards,

    Clara Gong

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

  • Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

    • leandross89's avatar
      leandross89
      Icon for Helper II rankHelper II

      You created a column called flag, and then, used the function fill up to complete with the value 10 the rows that have code A, It doesn´t works in my case because I have others rows in my index above this period presented. 

      • Ahmedx's avatar
        Ahmedx
        Icon for Super User rankSuper User

        post an example so I can help you

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi leandross89 ,

    Thanks to Ahmedx  for the reply, please allow me to provide another insight:
    1. Create a calculated column and populate the data in groups.

    Column =
    CALCULATE(MIN('Table'[Index]),FILTER(ALL('Table'),'Table'[Rule_rank] = "Rank" && 'Table'[Index] >= EARLIER('Table'[Index])) )

    2. Create a calculated column and display OK if it meets the conditions.

    Column 2 =
    IF('Table'[Index] < 'Table'[Column] && 'Table'[Searched] = 367 && 'Table'[Code] = "A" ,"OK")

    If your Current Period does not refer to this, please clarify in a follow-up reply.

     

    Best Regards,

    Clara Gong

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.