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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
nor303
Helper II
Helper II

How sum of two variables from an excel spreadsheet

Hi

 

Im new to Power BI and Im trying to sum two variables from an excel spreadsheet and call it something else. I want to sum A and C and call it G, and Sum B and E and call M for example. Is it possible to do this in the desk top without creating a new column in the data set? 

 

Thanks in advance!

 

A1000
B1500
C

600

D560
E800
F750
  
4 REPLIES 4
PhilipTreacy
Super User
Super User

Hi @nor303 

 

You can define names in the Excel workbook for your variables.  For example A_ and C_ for the cells where the corresponding values reside.

 

In Power Query, create a blank query and call it G.

 

open the Advanced Editor and use this code for this G query 

 

 

let
    A_ = Excel.CurrentWorkbook(){[Name="A_"]}[Content]{0}[Column1],
    C_ = Excel.CurrentWorkbook(){[Name="C_"]}[Content]{0}[Column1],
    Source = A_ + C_
in
    Source

 

 

The result of the query is 

 

gqr.png

 

Repeat this process for the other values/names you want to do calculations with.

 

The results of these queries can be used in other queries by using the query name, e.g.

 

 

let
    Source = G / 20
in
    Source

 

 

which gives the answer 80.

 

Regards

 

Phil

 

 

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


nor303
Helper II
Helper II

Thanks for your help! But not really the solution I was looking for. I was hoping that it was possible to make the formula within the desktop without making an extra column or shet. The reason is that next time I load a new updatet data set I was hoping that the formula automatically would do the same again.

Dhairya
Solution Supplier
Solution Supplier

Here we haven't added any new column, it's a measure which will automatically calculate the value when new data is added.
Still if you are not clear can you please share expected output?

Dhairya
Solution Supplier
Solution Supplier

Hey @nor303 
According to my understanding,
You have to first transpose this table in power query editor, which will look something like this

Dhairya_0-1687171099999.png


Then create following two Measures

G = SUM(Data[A])+SUM(Data[C])
M = SUM(Data[B])+SUM(Data[E])

After plotting all your columns and newly created measures in table visuals you will get following output
Dhairya_1-1687171533154.png


If it helps you please mark my solution as accepted.



Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.