Forum Discussion
Return rows with duplicates based on column status
Hi guys,
I have some data and it came from a manual entry CRM so it has alot of human errors. (which you will see in the Customer Stage, the status will be marked as XXX Error)
My objective is to filter out the Customer profile which is at the latest stage.
Customer Stage Flow Chart: Lead OR Lead Error -> Prospect OR Prospect Error-> Profile OR Profile Error (final stage)
Below is a piece of sample data I have:
| Customer | Profile Status | Asset |
| A | Lead | 10 |
| A | Prospect | 20 |
| B | Lead | 30 |
| B | Prospect | 30 |
| B | Profile | 50 |
| C | Lead | 40 |
| C | Profile | 60 |
| C | Profile | 60 |
| D | Lead | 15 |
| D | Prospect | 20 |
| D | Prospect Error | 20 |
| E | Profile | 5 |
| E | Profile Error | 5 |
The result I am looking for as per below:
| Customer | Profile Status | Asset |
| A | Prospect | 20 |
| B | Profile | 50 |
| C | Profile | 60 |
| C | Profile | 60 |
| D | Prospect | 20 |
| D | Prospect Error | 20 |
| E | Profile | 5 |
| E | Profile Error | 5 |
You will probably realize that there are still duplicates after the exercise, however, my goal here is not trying to de-dup but picking up the profile at their latest stages.
Lastly, if this can be done in power editor that would be great as I will need to join this table with other tables afterwards.
I tried approached this by creating order for the stages (stages 1 to 3), then grouping the customer, afterwards select the Max order desc, but this approach only return ONE record (which I willl need duplicate if it is in the same stage).
May I know if someone can help.
Any tips are apprecaited.
Thank you
- Anonymous2 years ago
Hi ljx0648 ,
I have created a simple sample, please refer to my pbix file to see if it helps you.
Create a measure.
Measure = VAR _1 = MAXX ( FILTER ( ALL ( 'Table' ), 'Table'[Customer ] = SELECTEDVALUE ( 'Table'[Customer ] ) ), 'Table'[Asset] ) RETURN IF ( MAX ( 'Table'[Asset] ) = _1, 1, BLANK () )Or a column.
Column = VAR _1 = MAXX ( FILTER ( ALL ( 'Table' ), 'Table'[Customer ] = EARLIER ( 'Table'[Customer ] ) ), 'Table'[Asset] ) RETURN IF ( ( 'Table'[Asset] ) = _1, 1, BLANK () )How to Get Your Question Answered Quickly - Microsoft Fabric Community
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- AnonymousNot applicable
Hi ljx0648 ,
I have created a simple sample, please refer to my pbix file to see if it helps you.
Create a measure.
Measure = VAR _1 = MAXX ( FILTER ( ALL ( 'Table' ), 'Table'[Customer ] = SELECTEDVALUE ( 'Table'[Customer ] ) ), 'Table'[Asset] ) RETURN IF ( MAX ( 'Table'[Asset] ) = _1, 1, BLANK () )Or a column.
Column = VAR _1 = MAXX ( FILTER ( ALL ( 'Table' ), 'Table'[Customer ] = EARLIER ( 'Table'[Customer ] ) ), 'Table'[Asset] ) RETURN IF ( ( 'Table'[Asset] ) = _1, 1, BLANK () )How to Get Your Question Answered Quickly - Microsoft Fabric Community
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.