Forum Discussion

mvgust's avatar
mvgust
Helper III
6 years ago
Solved

Set records filter based on specific values

I need to set a True/False column flag when the values in a table match the following:

 

IDs are the same and the Code=PTX

 

So in the below example, I would like a flag column which would indicate true on the highlighted records.

 

 

Thank you!

 

 

  • Hi mvgust ,

    I can also get the result using my previous formula:

    Attached my sample file that you can refer, please check and try it: Set records filter based on specific values.pbix

     

    Best Regards,
    Yingjie Li

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

3 Replies

  • v-yingjl's avatar
    v-yingjl
    Community Support

    Hi mvgust ,

    You can create a calcualte column like this:

    Flag =
    VAR _count =
        CALCULATE (
            COUNT ( 'Table'[Id] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Id] = EARLIER ( 'Table'[Id] )
                    && 'Table'[Code] = "PTX"
            )
        )
    RETURN
        IF ( _count = 1, TRUE (), FALSE () )

    Result:

     

    Best Regards,
    Yingjie Li

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

    • mvgust's avatar
      mvgust
      Helper III

      This is very close to what I need, however I do have the following scenario where the flag isn't catching a record:

       

       

      Thank you.

      • v-yingjl's avatar
        v-yingjl
        Community Support

        Hi mvgust ,

        I can also get the result using my previous formula:

        Attached my sample file that you can refer, please check and try it: Set records filter based on specific values.pbix

         

        Best Regards,
        Yingjie Li

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