Forum Discussion

tokyobaer's avatar
tokyobaer
Frequent Visitor
7 years ago
Solved

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?

5 Replies

    • tokyobaer's avatar
      tokyobaer
      Frequent Visitor

      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.

  • tokyobaer's avatar
    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".

      • tokyobaer's avatar
        tokyobaer
        Frequent Visitor

        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!