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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nosaj03
Helper II
Helper II

Creating a column with a sum of another column that repeats each row

Hey all, 

 

I am a complete noob at this so accept my apologies in advance if this is a very basic question.

 

Lets say I have a table of employee sales data for a specific office. 

 

I want to add a column that shows the total sales of the office so that I can also show what percentage their sales makes up from the total sales of the group.

 

How do I go about adding the column of total sales?

 

Every time I use the sum function for sales, it only provides me the sum for the individual employees and not of the group

 

Any help would be greatly appreciated. 

 

EmployeeSalesGroup SalesVariance
Emily1010010%
Joe2010020%
Sarah2010020%
Bill3010030%
John1010010%
Lisa1010010%
    
1 ACCEPTED SOLUTION
kentyler
Solution Sage
Solution Sage

2measures.PNG

Here you go.

Measure for calculating total sales:

Group Sales Measure = calculate(sum('Table'[Sales]),all('Table'[Employee]))
Measure for calculating variance
Variance Measure = VAR total_sales = [Group Sales Measure]
var individual_sales = selectedvalue('Table'[Sales])
RETURN Divide(individual_sales,total_sales)
I do a little video with commentary soon




Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


View solution in original post

7 REPLIES 7
kentyler
Solution Sage
Solution Sage

2measures.PNG

Here you go.

Measure for calculating total sales:

Group Sales Measure = calculate(sum('Table'[Sales]),all('Table'[Employee]))
Measure for calculating variance
Variance Measure = VAR total_sales = [Group Sales Measure]
var individual_sales = selectedvalue('Table'[Sales])
RETURN Divide(individual_sales,total_sales)
I do a little video with commentary soon




Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


@kentyler thank you so much for your expertise! It worked with unfiltered data but when the data is filtered ie filtering for a specific group of a company that has many groups, the data only returns the individual sales again.

 

How do I work around that?

that would be a variation on the theme

if you'd like to do a screen share to explore the possible solution

email me. i'm ken at 8thfold dot com

other wise please post some sample data, and we'll see if we can work it out

 





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


@kentyler actually I figured it out. I used the ALLSELECTED function with the names of Employee and group and it worked perfectly. Thanks again for all of your help.!!!!

Great Work!





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


I often feel its hard to provide enough context in a written answer. So here's a little video https://youtu.be/kW6JUh5mQ6I 





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


kentyler
Solution Sage
Solution Sage

This is what the ALL() function is in DAX for. 

I'll post a sample shortly.





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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