Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Condition based duplicate value set Flag

Hi Team,

 

I have below data, I want set "Flag" based on come columns condition.

 

For Flag one.

 

- If "Current Date" and "Load_date" same or not, If same date Group by "Route" & "City" & "SEQ NUM" and check "Truck_Assigned" X . If "Truck_Assigned" X then Flag is 1.
-  If "Current Date" and "Load_date" same or not, If same date Group by "Route" & "City" & "SEQ NUM" and check "Truck_Assigned" X not assigned but unique value then Flag is 1.

-If "Current Date" and "Load_date" same or not, If same date Group by "Route" & "City" & "SEQ NUM" and check "Truck_Assigned" X not assigned but two value then set any one of row as Flag is 1.

Route IDLoad_dateRouteCitySEQ NUMTruck_AssignedCurrent Date Flag
1234July 30,2020USABOHLock1XJuly 30,2020 1
4567July 21,2020USFRESFRE1XJuly 30,2020 0
7890July 30,2020USGA01WES1XJuly 30,2020 1
987July 30,2020USGA01VAL2 July 30,2020 1
6543July 30,2020USMA01OLI BR1 July 30,2020 0
3456July 30,2020USMA01OLI BR1 July 30,2020 0
7888July 30,2020USMA01OLI BR1XJuly 30,2020 1
2134July 30,2020USMA01OLI BR1XJuly 30,2020 1
5490July 30,2020USTN01LAV2 July 30,2020 1
5103July 30,2020USTN01LAV2 July 30,2020 0
4309July 30,2020USTN01LAKE1 July 30,2020 1

7 Replies

  • Anonymous you can use switch functon like this

     

    SWITCH ( TRUE(),
    Table[Column1] = "ABC" && Table[Column2] = "XYZ" && Table[Column3] = 123, "Value 1",
    Table[Column1] = "ABC" || ( Table[Column2] = "XYZ" && Table[Column3] = 123 ), "Value 2",
    Table[Column1] = "ABC" || Table[Column2] = "XYZ" || Table[Column3] = 123, "Value3",
    "Catch all"
    )
    
    

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

     

    • parry2k's avatar
      parry2k
      Super User

      Anonymous to add more

       

      && -> Is used for and condition

      || -> is used for or condition

       

      I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

      Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi,

         

        Thanks for reply.

         

        I Column value won't same always . We can't use switch condition.

        Logic is , On below record. I want display only lost two row data. Because It's assigned "X" and Don't want display which is no assigned X.

        6543July 30,2020USMA01OLI BR1 July 30,2020
        3456July 30,2020USMA01OLI BR1 July 30,2020
        7888July 30,2020USMA01OLI BR1XJuly 30,2020
        2134July 30,2020USMA01OLI BR1XJuly 30,2020


        One more logic, on below record. There no truck assigned. But For each combination I need consider one row as orginal record.

        5490July 30,2020USTN01LAV2 July 30,2020
        5103July 30,2020USTN01LAV2 July 30,2020
        4309July 30,2020USTN01LAKE1 July 30,2020
  • v-easonf-msft's avatar
    v-easonf-msft
    Community Support

    Hi , Anonymous 

     

    Could you please tell me whether your problem has been solved?
    If yes, you could accept the helpful answer as solution. You also could share your own solution here. For now, there is no content of description in the thread. If you still need help, please share more details to us.

     

    Best Regards,
    Community Support Team _ Eason