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
I_LOVE_POWER_BI
Helper III
Helper III

Add Column with percentage based on column attributes in the same table

Hi friends,

 

Simple question, I just don't know the correct DAX:

 

I_LOVE_POWER_BI_0-1622529441903.png

I have a table like the one above and want to ADD COLUMN which shows the result as above. The column shall calculate the percentage based on the attributes in the column Receipe.

 

Help! Thanks a thousand times!

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @I_LOVE_POWER_BI 

Please check the below.

 

Picture3.png

 

In Percentage CC =
'Table'[Weight]
/ CALCULATE ( SUM ( 'Table'[Weight] ), ALLEXCEPT ( 'Table', 'Table'[Receipe] ) )
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

4 REPLIES 4
jaideepnema
Solution Sage
Solution Sage

Hi @I_LOVE_POWER_BI ,

You can create a calculated column 

In % = 

var total=CALCULATE(SUM(Data[Weight]),ALLEXCEPT(Data,Data[Receipe]))

return DIVIDE(Data[Weight],total,0)

 

And create a matrix like this

jaideepnema_0-1622531574695.png

 

In case you want to use two columns and create a table then you can use calculated columns as shown below:

In % = 

var total=CALCULATE(SUM(Data[Weight]),ALLEXCEPT(Data,Data[Receipe]))

return DIVIDE(Data[Weight],total,0)
Total % = CALCULATE(SUM(Data[In %]),ALLEXCEPT(Data,Data[Receipe]))

and then create a table to get the desired result

jaideepnema_1-1622531709812.png

 

Hope this helps !!

 

Please accept this as a solution if your question has been answered !!

Appreciate a Kudos 😀

Jihwan_Kim
Super User
Super User

Hi, @I_LOVE_POWER_BI 

Please check the below.

 

Picture3.png

 

In Percentage CC =
'Table'[Weight]
/ CALCULATE ( SUM ( 'Table'[Weight] ), ALLEXCEPT ( 'Table', 'Table'[Receipe] ) )
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thanks Jihwan, it works! I did the same but I used ALL instead of ALLEXCEPT and got an error. Can you help me to understand what is the difference here?

 

Thanks!

Hi, @I_LOVE_POWER_BI 

Thank you for your feedback.

In my opinion, the All function clears all filters in the table. Allexcept function clears all filters except a certain column. In this case, the certain column is, I think, the Recipe column, and this column has to filter the formula.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.