Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
EUhlich
Frequent Visitor

Linking Parent and Child Items, Data in the same Table

Hello, I've got a problem I'm not able to solve...

 

In my source database, I have one table that contains all item information. It's connected via DirectQuery to PowerBI Desktop.

Generally speaking, the table consists of items with different hierarchies.
Something like this:

 

Items

 

ItemIDItemNameParentIDHierarchy
1Shorts Brown | XL31
2Shorts Brown | M31
3Shorts Brown72
4Shorts White | S61
5Shorts White | L61
6Shorts White-2
7Shorts73

 

I know it's not the best approach to storing the data, but I cannot change this source data.

 

Then I've got some other tables that contain customer order data. For Example:

 

Order Lines

 

OrderIDOrderLineIDItemIDPriceGross
100010000215
100110010110
100210015520

 

Now, I would like to be able to analyze the data based on the items I have.

I want to click ItemID 2 to get the price of 15.

I want to click ItemID 3 to get the summarized price of 25 for the "Shorts Brown".

I want to click ItemID 7 to get the summarized price of 45 for all sold "Shorts".

 

Up until now, I was not able to get this running.

I've tried with "importing" the same Items table multiple times, linking the different tables using the ItemID and ParentID, but I didn't get it to work.

I think this might be the way to go, but I'm not able to set this up correctly.

 

Any help is much appreciated.


Erik

 

 

PS: Sorry for the table formatting ... it looks different in the Edit Mode ...

2021-09-24_14h05_19.png

1 ACCEPTED SOLUTION
EUhlich
Frequent Visitor

Hi @lbendlin ,

 

thank you for your reply as well as the solution which really seems to be working when using the right mode! Unfortunately, I can not use the Storage Mode Import for the tables in question (Items & Order Lines).

 

But I think I managed to get what I need (although I'm not 100%  satisfied).
I just connected the Items table several times and used DirectQuery for every additional table.

Then I linked the tables with each other:

- OrderLines.ItemID < Items.ItemID

- Items.ItemID <> Items(1).ItemID

- Items(1).ParentID <> Items(2).ItemID

- Items(2).ParentID <> Items(3).ItemID

 

2021-09-27_13h30_42.png

 

Maybe this is helpful to others as well who purely use DirectQuery.
I'm not saying that this is the best approach and I'm really sure it isn't. But maybe it's something to work with.

View solution in original post

2 REPLIES 2
EUhlich
Frequent Visitor

Hi @lbendlin ,

 

thank you for your reply as well as the solution which really seems to be working when using the right mode! Unfortunately, I can not use the Storage Mode Import for the tables in question (Items & Order Lines).

 

But I think I managed to get what I need (although I'm not 100%  satisfied).
I just connected the Items table several times and used DirectQuery for every additional table.

Then I linked the tables with each other:

- OrderLines.ItemID < Items.ItemID

- Items.ItemID <> Items(1).ItemID

- Items(1).ParentID <> Items(2).ItemID

- Items(2).ParentID <> Items(3).ItemID

 

2021-09-27_13h30_42.png

 

Maybe this is helpful to others as well who purely use DirectQuery.
I'm not saying that this is the best approach and I'm really sure it isn't. But maybe it's something to work with.

lbendlin
Super User
Super User

Your hierarchy column isn't really needed.  Here is a sample implementation based on PATH().  You may need to check if that will work with your data source (make sure to enable the local data model option). See attached.

 

lbendlin_0-1632693539289.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.