Forum Discussion
DAX filter
Hi All,
Your help is required.
I have a table with ID details.
| ID | Dependecy | Age | Priority |
| 345 | Client | 12 | 1 |
| 385 | Supplier | 3 | 2 |
| 8425 | Paper Work | 5 | 1 |
| 998 | Client | 15 | 2 |
| 5428 | Client | 21 | 3 |
| 4832 | Client | 14 | 1 |
| 345 | Application | 44 | 1 |
| 441 | Client | 53 | 2 |
| 8425 | Client | 32 | 2 |
| 3382 | Client | 6 | 1 |
My output has to be
| ID |
| 998 |
| 4832 |
| 441 |
| 8425 |
Conditions to be satisfied:
- Priority = 1 or 2
- Age > 10
- 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
- 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
- Jihwan_Kim
Super User
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 ) )RETURNSUMMARIZE ( FILTER ( countdependency, [@count_dependency] = 1 ), Data[ID] )- Abbi
Helper 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
Community 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
Community Champion
Hi Abbi ,
Create a measure like this and use it as filter:-
_filter = count('Table (2)'[Dependecy ])Output:-
Thanks,
Samarth