Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Power Query -How to add additional rows, based on requirements, to a specifically structured dataset

Hi,
Below I have added a screenshot of the dataset I have. I have two requirements that I need to implement on top of this dataset. I do not believe this is doable in DAX so I am requesting this be complete using Power Query.

 

Requirement 1:
For each Division and Category, like a Group By, I require a new row creating with the text of 'SSGP' added as the Grouping_Level value, and the value field containing the sum (Sales - Costs). For example,

Division       Grouping_Level       Category       Value
South East   SSGP                       DEValue         (whatever the (Grouping_Level.Sales - Grouping_Level.Costs) calculation returns)
South East   SSGP                       DETarget        (whatever the (Grouping_Level.Sales - Grouping_Level.Costs) calculation returns)
South East   SSGP                       MTDValue      (whatever the (Grouping_Level.Sales - Grouping_Level.Costs) calculation returns)
South East   SSGP                       MTDTarget    (whatever the (Grouping_Level.Sales - Grouping_Level.Costs) calculation returns)

I require these additional rows added for each Division and Category. There are many Divisions but only the same four Category values for each Division and Grouping_Level.

Requirement 2:

For each Division and Category, again like a Group By, I require a new row creating with the text of 'Gross Profit' added as the Grouping_Level value, and the value field containing the sum (SSGP + FCP + CoS Adj + Customer Rebate + Settlement + Supplier Rebate). For example:
Dvision         Grouping_Level       Category     Value
South West  Gross Profit             DEValue       [SSGP] + [FCP] + [CoS Adj] + [Customer Rebate] + [Settlement] + [Supplier Rebate]
South West  Gross Profit             DETarget      [SSGP] + [FCP] + [CoS Adj] + [Customer Rebate] + [Settlement] + [Supplier Rebate]
South West  Gross Profit             MTDValue    [SSGP] + [FCP] + [CoS Adj] + [Customer Rebate] + [Settlement] + [Supplier Rebate]
South West  Gross Profit             MTDTarget  [SSGP] + [FCP] + [CoS Adj] + [Customer Rebate] + [Settlement] + [Supplier Rebate]

 

I require these additional rows added for each Division and Category. Again, there are many Divisions but only the same four Category values for each Division and Grouping_Level.

Please can someone help me achieve this?
Any help will much appreciated. Thanks in advance.


1 Reply

  • v-piga-msft's avatar
    v-piga-msft
    Resident Rockstar

    Hi Anonymous ,

     

    If it is convenient, could you share your data sample as table format and your desired output so that I can copy your data and test on it.

     

    Best Regards,

    Cherry