Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi everyone,
I need to create a calculated column (named ParentorChild in the example below) that identify me, for each week, the first duplicated ID as "Parent" and the remaining ones as "child". The Parent should always be the one with the lower UniqueID. Example in the table below:
UniqueID | Someother_ID | WeekYear | ParentorChild |
1 | ABC-123-XDR | 51-21 | Parent |
2 | DRF-546-CFR | 51-21 | Parent |
3 | BGT-433-FTT | 51-21 | Parent |
4 | ABC-123-XDR | 51-21 | Child |
5 | ABC-123-XDR | 52-21 | Parent |
6 | DRF-546-CFR | 52-21 | Parent |
7 | BGT-433-FTT | 52-21 | Parent |
8 | ABC-123-XDR | 52-21 | Child |
9 | ABC-123-XDR | 1-22 | Parent |
10 | DRF-546-CFR | 1-22 | Parent |
11 | BGT-433-FTT | 1-22 | Parent |
12 | ABC-123-XDR | 1-22 | Child |
13 | ABC-123-XDR | 1-22 | Child |
What is the best way to accomplish this?
Many thanks in advance for your time and support,
Joao Henriques
Solved! Go to Solution.
Hi @JMHenriques
Try this code to add a calculated column:
ParentorChild =
VAR _A =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER (
'Table',
'Table'[UniqueID] <= EARLIER ( 'Table'[UniqueID] )
&& 'Table'[WeekYear] = EARLIER ( 'Table'[WeekYear] )
&& 'Table'[Someother_ID] = EARLIER ( 'Table'[Someother_ID] )
)
)
RETURN
IF ( _A = 1, "Parent", "Child" )
output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
Hi @JMHenriques
Try this code to add a calculated column:
ParentorChild =
VAR _A =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER (
'Table',
'Table'[UniqueID] <= EARLIER ( 'Table'[UniqueID] )
&& 'Table'[WeekYear] = EARLIER ( 'Table'[WeekYear] )
&& 'Table'[Someother_ID] = EARLIER ( 'Table'[Someother_ID] )
)
)
RETURN
IF ( _A = 1, "Parent", "Child" )
output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
User | Count |
---|---|
106 | |
89 | |
81 | |
76 | |
73 |
User | Count |
---|---|
112 | |
104 | |
96 | |
74 | |
66 |