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
tokyobaer
Frequent Visitor

Distribute data over defined categories

I would appreciate support with the following problem. We are concerned with a project / ressource planning system: There are projects BM-001 to BM-006 that are planned on an hours basis with ressources RESS01 to RESS03 (Table 1).

 

PRJ-IDRessourceHours
BM-001RESS0112
BM-001RESS0223
BM-001RESS0334
BM-002RESS0256
BM-002RESS0367
BM-003RESS0189

 

Now the ressources are organized in groups: RESS02 is always in Grp4, RESS03 is always in Grp5 - but RESS01 is distributed over groups Grp1 to Grp3. This is done differently for each project - for some projects all of them are from one group (e. g. BM-003), for others there is a defined share (BM-001 to BM-002) - all organized in Table 2.

 

PRJ-IDGrp1Grp2Grp3
BM-00110%20%70%
BM-00220%40%40%
BM-0030%100%0%

 

So now we want to combine and transform both tables, desired result:

 

PRJ-IDRessourceGroupHours
BM-001RESS01Grp11,2
BM-001RESS01Grp22,4
BM-001RESS01Grp38,4
BM-001RESS02Grp423
BM-001RESS03Grp534
BM-002RESS01Grp111,2
BM-002RESS01Grp222,4
BM-002RESS01Grp322,4
BM-002RESS03Grp567
BM-003RESS01Grp289

 

A simple merge and unpivot does not do the job, leading to unwanted duplicates for RESS02 and RESS03. Any hint how this could be achieved in Power Query and / or DAX?

1 ACCEPTED SOLUTION

Hi @tokyobaer 

Sorry I missed that bit about RESS02/RESS03.  We can do it using two queries from table 1.  The first we filter to only RESS01 and apply table 2.  The second we filter out RESS01 then apply the GRP logic.  Finally we combined those table together.

groupsplit.jpg

I updated my .pbix file  https://www.dropbox.com/s/nipbf7dgs45t78r/ProjectHours.pbix?dl=0

 

View solution in original post

5 REPLIES 5
tokyobaer
Frequent Visitor

Correction: There was a typo in Table 1...

PRJ-IDRessourceHours
BM-001RESS0112
BM-001RESS0223
BM-001RESS0334
BM-002RESS0156
BM-002RESS0367
BM-003RESS0189

But this should not change anything about the previous discussion regarding the "partial unpivot".

Hi @tokyobaer 

Sorry I missed that bit about RESS02/RESS03.  We can do it using two queries from table 1.  The first we filter to only RESS01 and apply table 2.  The second we filter out RESS01 then apply the GRP logic.  Finally we combined those table together.

groupsplit.jpg

I updated my .pbix file  https://www.dropbox.com/s/nipbf7dgs45t78r/ProjectHours.pbix?dl=0

 

That's cool - it works exactly as I intended. With a bit of additional studying I learned a lot about Power Query and the M language over the weekend, and I am impressed... Thank you!

jdbuchanan71
Super User
Super User

@tokyobaer 

You have some lines in your output that I am not sure how you arrived at.  Amounts for Grp4 and Grp5 but they are not in table 2.  That being said, I think we can get what you are looking for by doing the unpivot on table 2 then removing the zeros before doing the merge and calc.

projecthours.jpg

I have posted my sample file here: https://www.dropbox.com/s/nipbf7dgs45t78r/ProjectHours.pbix?dl=0

Hey @jdbuchanan71 ,

thank you very much for your quick reply! As mentioned in my original post, RESS02 is always in Grp4 and RESS03 is always in Grp5. So if you want, there is another Table 2B:

 

RessourceGroup
RESS01Shared (see Table 2)
RESS02Grp4
RESS03Grp5

 

That is why a direct unpivot / merge did not work out - it should only be performed on the RESS01, while for RESS02/RESS03 there is the other rule (Table 2A). Somehow a "partial unpivot" transformation.

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.