Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello all
I am struggling quite a lot with the following case. What I want to achieve is to create a column (important) per row that calculates the ratio of a value of that row, to the total by a group. Below is an example with excel with the formula:
So, the highlighted column is what I want. For example row 2 , the 11,8 is calculated as a the value (B2) to the sum of the cars . The reason I need a column is that I want to use these weights later for creating another column.
When I create the following formula alone in Power BI to get totals per group, it works fine:
Sum_per_group = CALCULATE(SUM(RawData[Sales),RawData[Type]=RawData[Type])
If i then enter the value , so to find the ratio , as per below, I get only "Nan" ! (I added only the [Sales]/ )
Ratio = [Sales] / CALCULATE(SUM(RawData[Sales),RawData[Type]=RawData[Type])
What am I doing wrong? 😕
Solved! Go to Solution.
@phoenix20 wrote:
Hello all
I am struggling quite a lot with the following case. What I want to achieve is to create a column (important) per row that calculates the ratio of a value of that row, to the total by a group. Below is an example with excel with the formula:
So, the highlighted column is what I want. For example row 2 , the 11,8 is calculated as a the value (B2) to the sum of the cars . The reason I need a column is that I want to use these weights later for creating another column.
When I create the following formula alone in Power BI to get totals per group, it works fine:
Sum_per_group = CALCULATE(SUM(RawData[Sales),RawData[Type]=RawData[Type])
If i then enter the value , so to find the ratio , as per below, I get only "Nan" ! (I added only the [Sales]/ )
Ratio = [Sales] / CALCULATE(SUM(RawData[Sales),RawData[Type]=RawData[Type])
What am I doing wrong? 😕
You can try to create a calculated column as below. See attached pbix file.
Ratio To Type = RawData[Sales] / CALCULATE ( SUM ( RawData[Sales] ), ALLEXCEPT ( RawData, RawData[Type] ) )
@phoenix20 wrote:
Hello all
I am struggling quite a lot with the following case. What I want to achieve is to create a column (important) per row that calculates the ratio of a value of that row, to the total by a group. Below is an example with excel with the formula:
So, the highlighted column is what I want. For example row 2 , the 11,8 is calculated as a the value (B2) to the sum of the cars . The reason I need a column is that I want to use these weights later for creating another column.
When I create the following formula alone in Power BI to get totals per group, it works fine:
Sum_per_group = CALCULATE(SUM(RawData[Sales),RawData[Type]=RawData[Type])
If i then enter the value , so to find the ratio , as per below, I get only "Nan" ! (I added only the [Sales]/ )
Ratio = [Sales] / CALCULATE(SUM(RawData[Sales),RawData[Type]=RawData[Type])
What am I doing wrong? 😕
You can try to create a calculated column as below. See attached pbix file.
Ratio To Type = RawData[Sales] / CALCULATE ( SUM ( RawData[Sales] ), ALLEXCEPT ( RawData, RawData[Type] ) )
Hi @phoenix20,
Try this clculated column formula
=SUM(Data[Sales])/CALCULATE(SUM(Data[Sales]),FILTER(Data,Data[Type]=EARLIER(Data[Type])))
Hope this helps.
Hi @phoenix20,
Try:
SalesbyGroup = CALCULATE(SUM('Table'[sales]),ALLEXCEPT('Table', 'Table'[Type]))
Ratio = DIVIDE([Total Sales],[SalesbyGroup])
This should give you the desired outcome.
Rgds,
Dave
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
72 | |
68 | |
41 | |
35 |
User | Count |
---|---|
108 | |
56 | |
52 | |
48 | |
41 |