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
Anonymous
Not applicable

How to calculate the percentage based on column and slice selection

Hi team, I am very new to Power BI and come across my first question,  I have a table where contains the sales amount and team, dates, sample as below: 

Agent name Agent TeamSales dateSales total
LucyTeam A30/07/20203
Marin Team A31/09/20202
CharcyTeam B1/08/20201
Chris Team C2/08/20205

 

I am using Agent team as a slice in Power BI,  then I want to calculate the percentage of Sales of each person baes on my selection of teams,  for example, if I dont select any team then it will be calculated based on the whole table, the result will be like: 

 Sales total Percentage
Lucy327.27%
Marin 218.18%
Charcy19.09%
Chris 545.45%

but if I select Team A, the percentage will need to calculates based on the total sales of Team A. 

 Sales total Percentage
Lucy360.00%
Marin 240.00%

I know we can use the "Percentage of grad total" to show similar results, but I would like to create it as a measure so I can re-use this value.

I tried to use DAX below: 

Pct Team =
VAR Personal =
sum('table'[Sales Total])
VAR ALLteam=
SUMX(
all('table'),
'table'[Sales Total]
)
DIVIDE(Personal, ALLteam)
But that won't give what I want, anyone can help pls? : ) 
 
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Try with allselected

Pct Team =
VAR Personal =
sum('table'[Sales Total])
VAR ALLteam=
SUMX(
allselected('table'),
'table'[Sales Total]
)
DIVIDE(Personal, ALLteam)

View solution in original post

Anonymous
Not applicable

It worked, thanks 🙂 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Try with allselected

Pct Team =
VAR Personal =
sum('table'[Sales Total])
VAR ALLteam=
SUMX(
allselected('table'),
'table'[Sales Total]
)
DIVIDE(Personal, ALLteam)

Anonymous
Not applicable

It worked, thanks 🙂 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors