Forum Discussion
how to find same Position id is associate to multiple Resurce ids using DAX
Hi ,
Can anyone help on below query?
Data given below
| Position ID | Resource_ID |
| P_00001 | R_0001 |
| P_00001 | R_0002 |
| P_0123 | R_01 |
| P_0123 | R_02 |
| P_456 | R_90 |
| P_456 | R_80 |
| P_567 | R_4 |
| P_876 | R_5 |
| P_36 | R_6 |
I need to get same Position id is associate to multiple Resurce ids using DAX.
Expected output
| Position ID | Resource_ID |
| P_00001 | R_0001 |
| P_00001 | R_0002 |
| P_0123 | R_01 |
| P_0123 | R_02 |
| P_456 | R_90 |
| P_456 | R_80 |
Regards,
Triveni N.
Hi TriveniN
How would you like to achieve this?
In the query editor to remove the data before being brough into the report or as a table visual in the Report view?
As a table visual apply a filter where the DistinctCount > 1Create a measure that checks the distinct count and then use this in the filter pane.
Distinct ResourceID =CALCULATE(DISTINCTCOUNT('Table'[Resource_ID]), all('Table'[Resource_ID]))Or in the query editor merge the table to itselfThen change the aggregation to Count ResourceID
Use the dropdown to filter to not 1
Now those rows wont be imported into the model at all.
Hello TriveniN ,
Do you want a measure instead ? Your expected output from screenshot is a table with two columns.
You can modify query to get position_id only :
Selected =SUMMARIZE (FILTER ('Sample',CALCULATE ( COUNT ( 'Sample'[Resource_ID] ), ALLEXCEPT ( 'Sample', 'Sample'[Position_ID] ) ) > 1),'Sample'[Position_ID])I f you want a measure to show number of position_ids having more than 1 resource_Ids, use below query:Selected_POs_Measure =CALCULATE (DISTINCTCOUNT ( 'Sample'[Position_ID] ),FILTER ('Sample',CALCULATE ( COUNT ( 'Sample'[Resource_ID] ), ALLEXCEPT ( 'Sample', 'Sample'[Position_ID] ) ) > 1))I hope this helpsCheers
6 Replies
- SamWiseOwl
Super User
Hi TriveniN
How would you like to achieve this?
In the query editor to remove the data before being brough into the report or as a table visual in the Report view?
As a table visual apply a filter where the DistinctCount > 1Create a measure that checks the distinct count and then use this in the filter pane.
Distinct ResourceID =CALCULATE(DISTINCTCOUNT('Table'[Resource_ID]), all('Table'[Resource_ID]))Or in the query editor merge the table to itselfThen change the aggregation to Count ResourceID
Use the dropdown to filter to not 1
Now those rows wont be imported into the model at all.
- Kedar_Pande
Super User
Create a new table:
FilteredTable1 =
VAR PositionCounts =
SUMMARIZE(
'Table',
'Table'[Position ID],
"Count", COUNTROWS('Table')
)
RETURN
FILTER(
'Table',
'Table'[Position ID] IN
SELECTCOLUMNS(
FILTER(PositionCounts, [Count] > 1),
"Position ID", 'Table'[Position ID]
)
)If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn- TriveniN
Helper II
Getting all the records irrespective of position id
- divyed
Super User
Hello TriveniN ,
Please use below DAX to filter your table :
Selected_Positions =FILTER ('Sample',CALCULATE ( COUNT ( 'Sample'[Resource_ID] ), ALLEXCEPT ( 'Sample', 'Sample'[Position_ID] ) ) > 1)I hope this is what you are looking for. Please mark this as a solution if this has fixed your issue. Want to say special thank you , press a kudos button 🙂
Cheers
- TriveniN
Helper II
The expression refers to multiple columns. Multiple columns can't be converted to scalar value
- divyed
Super User
Hello TriveniN ,
Do you want a measure instead ? Your expected output from screenshot is a table with two columns.
You can modify query to get position_id only :
Selected =SUMMARIZE (FILTER ('Sample',CALCULATE ( COUNT ( 'Sample'[Resource_ID] ), ALLEXCEPT ( 'Sample', 'Sample'[Position_ID] ) ) > 1),'Sample'[Position_ID])I f you want a measure to show number of position_ids having more than 1 resource_Ids, use below query:Selected_POs_Measure =CALCULATE (DISTINCTCOUNT ( 'Sample'[Position_ID] ),FILTER ('Sample',CALCULATE ( COUNT ( 'Sample'[Resource_ID] ), ALLEXCEPT ( 'Sample', 'Sample'[Position_ID] ) ) > 1))I hope this helpsCheers