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
jbezos
New Member

Creating Measures

 

 

Hi, First time using Power BI.  I'm trying to calculate the % distribution based on the values found in a column.  For example, I have a column of Fruits with Apples and Bananas as values.  I am trying to calulate the % highlighted in yellow.

 

 

Capture.GIF

THanks!

1 ACCEPTED SOLUTION
v-sihou-msft
Employee
Employee

@jbezos

 

As @Phil_Seamark said, it's better to pivot your dataset like:

 

67.PNG

 

You can use a matrix to render your data. Then you just need to create a measure to calculate the percentage of month total for current fruit.

 

Pct Of Month Total = SUM(Fruits[Volume])/CALCULATE(SUM(Fruits[Volume]),ALLEXCEPT(Fruits,Fruits[Month]))

8.PNG

 

 

Regards,

View solution in original post

2 REPLIES 2
v-sihou-msft
Employee
Employee

@jbezos

 

As @Phil_Seamark said, it's better to pivot your dataset like:

 

67.PNG

 

You can use a matrix to render your data. Then you just need to create a measure to calculate the percentage of month total for current fruit.

 

Pct Of Month Total = SUM(Fruits[Volume])/CALCULATE(SUM(Fruits[Volume]),ALLEXCEPT(Fruits,Fruits[Month]))

8.PNG

 

 

Regards,

Phil_Seamark
Employee
Employee

Hi @jbezos

 

I suggest you pivot your data to the following structure.

 

Month    , Fruit  , Value
------------------------------
1 Jan 17 , Apples , 1
1 Feb 17 , Apples , 5
1 Mar 17 , Apples , 15
1 Jan 17 , Bananas, 4
1 Feb 17 , Bananas, 10
1 Feb 17 , Bananas, 20

Once you have this structure you can create some measures like

 

Sum of Value = CALCULATE(SUM([Value]))

which you can drag to a matrix visual (Month on Rows, Fruit on Columns), twice.  The second time you add the measure to the grid, set the "show as percentage"

 

I think that will be close.

 

You can change the structure of your data in the Query Editor using the Unpivot function.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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.