Forum Discussion

Abbi's avatar
Abbi
Icon for Helper I rankHelper I
4 years ago

DAX filter

Hi All,

 

Your help is required.

I have a table with ID details. 

IDDependecy AgePriority
345Client121
385Supplier32
8425Paper Work51
998Client152
5428Client213
4832Client141
345Application441
441Client532
8425Client322
3382Client61

 

My output has to be 

ID
998
4832
441
8425

 

Conditions to be satisfied:

  1. Priority = 1 or 2
  2. Age > 10
  3. After satisfying the first 2 conditions, if the ID has only 1 dependency (i.e. Client) then we have to get the ID to the table
  4. After satisfying the first 2 filters, if the ID has more than 1 dependency then we shouldn’t get the ID to the table.

 

I was able to apply first 2 conditions, but 3rd condition is not striking my head.

 

Please help.

 

4 Replies

  • Hi,

    Please check the below. It is for creating a new table.

     

     

    New table =
    VAR newtable =
    FILTER ( Data, Data[Priority] IN { 1, 2 } && Data[Age] > 10 )
    VAR countdependency =
    GROUPBY ( newtable, Data[ID], "@count_dependency", SUMX ( CURRENTGROUP (), 1 ) )
    RETURN
    SUMMARIZE ( FILTER ( countdependency, [@count_dependency] = 1 ), Data[ID] )
    • Abbi's avatar
      Abbi
      Icon for Helper I rankHelper I

      Jihwan_Kim Samarth_18 , Sorry if I had lead you in wrong way.

      Here the condition is not count of dependency, We require only ID'd with Client dependency. If the ID has Client and Application dependecy and both of them satify the priority and age conditions then we shouldn't pull that ID.

       

      We have to pull only the ID's ( can be repeated any number of times), but it has only Client dependecy .

       

       

      • v-jingzhang's avatar
        v-jingzhang
        Icon for Community Support rankCommunity Support

        Hi Abbi 

         

        Use below measure as a filter field on the table visual to get the result. SELECTEDVALUE() returns a single dependency value. If an ID has more than one dependencies, it will return blank. 

        Flag = 
        VAR _dependency =
            CALCULATE (
                SELECTEDVALUE ( 'Table'[Dependecy ] ),
                FILTER ( 'Table', 'Table'[Priority] IN { 1, 2 } && 'Table'[Age] > 10 )
            )
        RETURN
            IF ( _dependency = "Client", 1, 0 )

         

        Or if you want to have the filtered result in a new table, you can use 

        Table 2 = 
        SELECTCOLUMNS (
            FILTER (
                SUMMARIZE (
                    FILTER ( 'Table', 'Table'[Priority] IN { 1, 2 } && 'Table'[Age] > 10 ),
                    'Table'[ID],
                    "dependency", SELECTEDVALUE ( 'Table'[Dependecy ] )
                ),
                [dependency] = "Client"
            ),
            "id", [ID]
        )

         

        Best Regards,
        Community Support Team _ Jing
        If this post helps, please Accept it as Solution to help other members find it.

  • Samarth_18's avatar
    Samarth_18
    Icon for Community Champion rankCommunity Champion

    Hi Abbi ,

     

    Create a measure like this and use it as filter:-

    _filter = count('Table (2)'[Dependecy ])

     Output:-

    Thanks,

    Samarth