cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ankitkalsara
Helper I
Helper I

Parent and Child Hierarchy

Hi team,

 

I need your help to calculate 2 new columns based on below dataset. Link to PBIX file

 

My dataset contains part numbers and I want to calculate 2 columns "Master Variant" and "Variant type" as below.

1.png

Any help is much appreciated. 

1 ACCEPTED SOLUTION
Bifinity_75
Solution Sage
Solution Sage

Hi @ankitkalsara, Possibly not the most elegant solution, but it works.

 

1.- Duplicate your table in Power Query, and filter youy duplicate column by delimiter "-":

Bifinity_75_0-1668797806052.png

 

2.- Insert a custom column and extract 3 first character: write this formule:

=Text.Start([Part Number],3)

Bifinity_75_1-1668797870686.png

 

3.- Group by new column create like the image:

Bifinity_75_2-1668797982861.png

 

4.- The final result in Power query has to be like this:

Bifinity_75_3-1668798022309.png

 

5.- You must have created the relationship between:

Bifinity_75_4-1668798161689.png

 

6.- You can create the calculate column:

Master Variant = if(RELATED('Table (2)'[Part Number 3])>0,"Yes","No")

 

7.- Another calculate column:

Variant Type = if(
        LEN('Table'[Part Number])<4 && 'Table'[Master Variant]="No",
        "Standard Variant", "Multiple Variant"
                )

 

8.- The result:

Bifinity_75_5-1668798308865.png

 

I hope works for you. Best regards

 

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @ankitkalsara ,

According to your description, here's my solution. Create two calculated columns.

Master Variant =
IF (
    CONTAINSSTRING ( 'Table'[Part Number], "-" ),
    "No",
    IF (
        COUNTROWS (
            FILTER (
                'Table',
                'Table'[Part Number] <> EARLIER ( 'Table'[Part Number] )
                    && CONTAINSSTRING ( 'Table'[Part Number], EARLIER ( 'Table'[Part Number] ) )
            )
        ) > 0,
        "Yes",
        "No"
    )
)
Variant type =
IF (
    [Master Variant] = "Yes"
        || CONTAINSSTRING ( 'Table'[Part Number], "-" ),
    "Multiple Variant",
    "Standard Variant"
)

Get the correct result:

vkalyjmsft_0-1669021252412.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Bifinity_75
Solution Sage
Solution Sage

Hi @ankitkalsara, Possibly not the most elegant solution, but it works.

 

1.- Duplicate your table in Power Query, and filter youy duplicate column by delimiter "-":

Bifinity_75_0-1668797806052.png

 

2.- Insert a custom column and extract 3 first character: write this formule:

=Text.Start([Part Number],3)

Bifinity_75_1-1668797870686.png

 

3.- Group by new column create like the image:

Bifinity_75_2-1668797982861.png

 

4.- The final result in Power query has to be like this:

Bifinity_75_3-1668798022309.png

 

5.- You must have created the relationship between:

Bifinity_75_4-1668798161689.png

 

6.- You can create the calculate column:

Master Variant = if(RELATED('Table (2)'[Part Number 3])>0,"Yes","No")

 

7.- Another calculate column:

Variant Type = if(
        LEN('Table'[Part Number])<4 && 'Table'[Master Variant]="No",
        "Standard Variant", "Multiple Variant"
                )

 

8.- The result:

Bifinity_75_5-1668798308865.png

 

I hope works for you. Best regards

 

Helpful resources

Announcements
Join Arun Ulag at MPPC23

Join Arun Ulag at MPPC23

Get a sneak peek into this year's Power Platform Conference Keynote.

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Top Solution Authors