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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
sabhishek
Frequent Visitor

Need Help On Power Query Code

Can somebody help me with the Power Query code by which I can update the value for Column Spend for against ProductTitle Diff whose formula is Base = 1 – SUM(Spend). Data may increase and pattern is shown below. The source is SharePoint list. I will have to show this data on Donut chart in Power BI.

 

Spend   ReportDate    ProductTitle                  Spend       ReportDate    ProductTitle
0.3        5/4/2016      A                                    0.3          5/4/2016        A
0.53      5/4/2016      B                                    0.53        5/4/2016        B
             5/4/2016     Base                                0.17        5/4/2016       Base

Spend     ReportDate   ProductTitle                 Spend     ReportDate      ProductTitle
0.3          5/4/2016      A                                 0.3          5/4/2016         A
0.53        5/4/2016      B                                 0.53        5/4/2016         B
               5/4/2016    Base                              0.17        5/4/2016        Base
0.5          6/5/2016    A                                   0.5          6/5/2016        A
0.38        6/5/2016    B                                   0.38        6/5/2016        B
               6/5/2016    Base                              0.12        6/5/2016        Base


1 ACCEPTED SOLUTION
Habib
Continued Contributor
Continued Contributor

Here are the detailed steps for achieving this. I am asuming that your Product title has same pattren.

 

I have used below sample data in excel

 

stepq.png

Connected with Excel and edit the query

 

step2.png

After this remove the two steps from right area "Chagne Type" and Promoted Headers". It will bring your column hearders as data row. Now remove first row by going to Home Table and clicking Remove Rows button. You need to mention 1 as number of rows to be deleted.

 

Now your data set will look like this.

 

step3.png

Now select Column3 and click on Pivot Column button under Transformations Tab

 

step4.png

select Column1 as Value column in popup and click Ok. It will pivot your data to a new format as below

 

step5.png

Now remove the Base Column and Add new Column Base with Below Formula

 

step6.png

You base value has been calculated. See below for reference

 

step7.png

View solution in original post

2 REPLIES 2
Habib
Continued Contributor
Continued Contributor

Here are the detailed steps for achieving this. I am asuming that your Product title has same pattren.

 

I have used below sample data in excel

 

stepq.png

Connected with Excel and edit the query

 

step2.png

After this remove the two steps from right area "Chagne Type" and Promoted Headers". It will bring your column hearders as data row. Now remove first row by going to Home Table and clicking Remove Rows button. You need to mention 1 as number of rows to be deleted.

 

Now your data set will look like this.

 

step3.png

Now select Column3 and click on Pivot Column button under Transformations Tab

 

step4.png

select Column1 as Value column in popup and click Ok. It will pivot your data to a new format as below

 

step5.png

Now remove the Base Column and Add new Column Base with Below Formula

 

step6.png

You base value has been calculated. See below for reference

 

step7.png

Thank You so much Habib for your time and support. This solution has helped me to complete my task. Thanks again...Smiley Happy

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.