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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
james_pease
Helper III
Helper III

Sum of a calculated column

Hello everyone, does anyone know how to calculate the sum of a calculated column? Im trying to create a few measures that use calculated columns for values but they are returning blanks. 

james_pease_0-1662154675804.png

Here are my expressions:

measure:
xsqrsum = sum('All_Actual_Sales (2)'[xsq])
Calculated column being referenced: 
xsq = if('All_Actual_Sales (2)'[LN Actual Sales]>0,('All_Actual_Sales (2)'[LN Actual Sales])^2)

Calculated column being referenced:

LN Actual Sales = If('All_Actual_Sales (2)'[Actual Sales Null Values]>0,ln('All_Actual_Sales (2)'[Actual Sales Null Values]))


Measure: 

xsum = sumx( 'All_Actual_Sales (2)',[LN Actual Sales])
Calculated column being referenced

LN Actual Sales = If('All_Actual_Sales (2)'[Actual Sales Null Values]>0,ln('All_Actual_Sales (2)'[Actual Sales Null Values]))

 

Measure:

xysum = sum('All_Actual_Sales (2)'[xy])
Calculated column being reference:
xy = if('All_Actual_Sales (2)'[Actual Sales Null Values]>0, sum('All_Actual_Sales (2)'[LN Actual Sales])*sum('All_Actual_Expenses (2)'[Amount]))
 
Measure:
y-intercept = Divide(
            [ysum]*[xsqrsum]-[xsum]*[ysum],
            [n]*[xsqrsum]-[xsum]^2)
Calculated coulmns being referenced xsq and xy from above.
 
So I know my issues stem from not being able to sum the calculated columns.
 
Thanks in advance!
 
1 ACCEPTED SOLUTION

The problem is I am expecting to get a number as the total (sum of a calculated column should be a number). I am not getting a number, I am getting a blank. So then when I try and caclulate the sum of xy, the y-intercept, and the slope I received blanks because the sum of x is blank. Lastly, when I try and plug everything into the regression formula, the result is blank because the above are blank. 

 

My new approach is to append two queriers into 1 then use filter or if expressions to sum charts with an expense account number and revenues with revenue account numbers. 

View solution in original post

2 REPLIES 2
daXtreme
Solution Sage
Solution Sage

OK, you've shown your formulas but you have not shown were the problem really is... Calculated columns are normal columns in a table and they definitely can be used as any other column. Do you get any error? If so, why don't you show it?

The problem is I am expecting to get a number as the total (sum of a calculated column should be a number). I am not getting a number, I am getting a blank. So then when I try and caclulate the sum of xy, the y-intercept, and the slope I received blanks because the sum of x is blank. Lastly, when I try and plug everything into the regression formula, the result is blank because the above are blank. 

 

My new approach is to append two queriers into 1 then use filter or if expressions to sum charts with an expense account number and revenues with revenue account numbers. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.