Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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/
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
104 | |
79 | |
68 | |
61 |
User | Count |
---|---|
144 | |
104 | |
103 | |
82 | |
70 |