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
SUMESHKUMAR22
Helper IV
Helper IV

Calculate average based on same category

Hi Everyone,
Good day!
As per the below snapshot I want to create a new measure where the marked percentage numbers should get averaged beacuse it lies under the same category of column A but column B is divided into sub category so, I have to average those numbers but in the total section it should take one percentage (like 40.00% + 53.33% = 46.66% but in the total average calcualtion it should be considered once  .

Margin formula = c-d/d

Capture.PNG
Untitled.png

Thanks in advance,
Sumesh

1 ACCEPTED SOLUTION

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

hello @SUMESHKUMAR22 ,
please try:

 

margin average = CALCULATE(AVERAGE(powerbi[Margin]),ALLEXCEPT(powerbi,powerbi[a]))

 

 

Screenshot 2022-11-02 144355.png

Hi @Anonymous ,
This is coming up fine at category level. But in the total average instead of 49.56% it should come up 48.70%. That is dividng the average by distinct table[a] values.

Thanks you!

Greg_Deckler
Super User
Super User

@SUMESHKUMAR22 Try:

Measure = 
  VAR __a = SELECTCOLUMNS('Table'[a])
  VAR __Result = 
    AVERAGEX(
      SUMMARIZE(FILTER(ALL('Table'),[a] IN __a),[a],[b], "__T_margin%",[T_margin%]),
      [__T_margin%]
    )
RETURN
  __Result

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ,
Thanks for prompt response!
The final total avergae should come up 48.70% instead of 49.56% . As we will not consider the repetitve percentage values as per the Table[a] disitnct values.
Untitled.png

Hi @Greg_Deckler , @Anonymous 

Below is the total average (Result), I'm expecting in your above measure.
The blank that is coming shouldn't come up and give the total result as 48.70% .

Capture.PNG

Thanks in advance!

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.