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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

The percentage calculating incorrectly

Dear All,

 

I have economic activities, for example, activity 1, ..., activity n. Further, activities contain X number of companies. Profit of the activity is formed by the sum of profits of companies that belongs to this activity. So currently I need to calculate the share of companies within the economic activity. 

 

I am using the following measure:

Share company= 100*(DIVIDE((SUM(Powerbi[Profit])),CALCULATE(SUM(Powerbi[Profit]), Powerbi[Company], Powerbi[Economic activities])))

 

Unfortunately this calculating company shares from the total profit of all economic activities. So, total profit 5 000 000, while total profit for activity 1 is equal to 4 000 000. Therefore, the share of companies that belongs to activity 1 is calculating from 5 000 000 not 4 000 000. Where is my mistake?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

I see your latest screenshot. Do you have two tables in your data model? There should be key columns like [Economic Activity] in both tables. Or you couldn't relate two tables in your calcualte.

Activity Table:

1.png

Company Table:

2.png

Measure:

Percentage = 
VAR _Total = CALCULATE(SUM(Activity[Profit]),FILTER(Activity,Activity[Economic activities] = EARLIER(Company[Activity])))
RETURN
DIVIDE(Company[Profit],_Total)

Result:

3.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  

View solution in original post

10 REPLIES 10
speedramps
Community Champion
Community Champion

Hi manap

 

Click here to download a solution 

 

Please leave kudos if it solves your problem

 

It is best practive to breakdown complex DAX measure into easy chunks that you can test and reuse ....

 

I have created 3 measures and used a % format rather than multiply by 100


Profits =
-- get the profits
SUM(Sales[Profit])


Profit for all companies =
-- get profit for all companies within the current context.
-- The ALL command with keep the row Activity context but changes the row Company context to all.
CALCULATE(
[Profits],
ALL(Sales[Company])
)

 

 

% profit of all activity =
-- get the % of profits for all the activity
DIVIDE( [Profits] , [Profit for all companies] )

Anonymous
Not applicable

I have tried your method, but it resulted 1 for all companies

Anonymous
Not applicable

Hi @Anonymous 

I see your latest screenshot. Do you have two tables in your data model? There should be key columns like [Economic Activity] in both tables. Or you couldn't relate two tables in your calcualte.

Activity Table:

1.png

Company Table:

2.png

Measure:

Percentage = 
VAR _Total = CALCULATE(SUM(Activity[Profit]),FILTER(Activity,Activity[Economic activities] = EARLIER(Company[Activity])))
RETURN
DIVIDE(Company[Profit],_Total)

Result:

3.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  

PaulDBrown
Community Champion
Community Champion

Please provide sample data or a PBIX file and a depiction of the expected outcome 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

manap_0-1633945541784.png

Here is a screenshort 

We are going to need sample data of the actual structure of the tables. The depiction you have provided does not allow to establish a relationship between the two tables shown.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

What about this

manap_0-1633948716767.png

 

Anonymous
Not applicable

@Anonymous try this:

Share company=var CurrentActivity=Powerbi[Economic activities]

return DIVIDE(SUM(Powerbi[Profit]),SUMX(FILTER(Powerbi,Powerbi[Economic activities]=CurrentActivity),Powerbi[Profit]))*100

 

Anonymous
Not applicable

how to create this var CurrentActivity=Powerbi[Economic activities] if I have a column.

Anonymous
Not applicable

@Anonymous wrap the column into VALUES(), that is:

var CurrentActivity=VALUES(Powerbi[Economic activities])

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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