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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
TomerIwanir1
Helper I
Helper I

% calculation per row

Hello

I'm trying to create a calculate column of cost % out of total cost with filters, attaching the pic below for example 

I have two column that filtering my calc, the right column (cost %) is what im trying to create, please note that I have a lot of month and products so creating a measure oer each one is not relevent.

 

thx again !

 

TomerIwanir1_0-1727074282642.png

 

1 ACCEPTED SOLUTION

@TomerIwanir1 

 

I think you forgot to write "Filter". so write it as follows:

Product_Share = 'Sales'[Total Cost (Calc)] / CALCULATE(SUM('Sales'[Total Cost (Calc)]),Filter ('Sales','Sales'[Month] = EARLIER('Sales'[Month]) && 'Sales'[Product_Group (Calc)] = EARLIER('Sales'[Product_Group (Calc)]))

 

* I highlight updated part*

 

If this post helps, then I would appreciate a thumbs up  and mark it as the solution to help the other members find it more quickly. 

View solution in original post

6 REPLIES 6
TomerIwanir1
Helper I
Helper I

I'm getting all 100 %

Product_Share = 'Sales'[Total Cost (Calc)] / CALCULATE(SUM('Sales'[Total Cost (Calc)]),'Sales'[Month] = EARLIER('Sales'[Month]),'Sales'[Product_Group (Calc)] = EARLIER('Sales'[Product_Group (Calc)]))
 
where cost is a decimal number,month is a date and product is text

@TomerIwanir1 

Are you sure that you have written a column , and not measure??

I think so, pls see below :

 

TomerIwanir1_0-1727090991415.png

 

@TomerIwanir1 

 

I think you forgot to write "Filter". so write it as follows:

Product_Share = 'Sales'[Total Cost (Calc)] / CALCULATE(SUM('Sales'[Total Cost (Calc)]),Filter ('Sales','Sales'[Month] = EARLIER('Sales'[Month]) && 'Sales'[Product_Group (Calc)] = EARLIER('Sales'[Product_Group (Calc)]))

 

* I highlight updated part*

 

If this post helps, then I would appreciate a thumbs up  and mark it as the solution to help the other members find it more quickly. 

Yes ! I changed the "," into "&&" at the filter:
 
product_Share = 'Sales'[Total Cost (Calc)] / CALCULATE(SUM('Sales'[Total Cost (Calc)]),FILTER(Sales,Sales[Month] = EARLIER(Sales[Month])&& Sales[Product_Group (Calc)] = EARLIER(Sales[Product_Group (Calc)])))
 
 
thank you !
Selva-Salimi
Super User
Super User

Hi @TomerIwanir1 

You can write a column as follows and change the format as percentage:

 

Product_Share := Cost / calculate(sum(cost) , filter (your_table , period= earlier (period) && product= earlier (product))

 

If this post helps, then I would appreciate a thumbs up  and mark it as the solution to help the other members find it more quickly. 

 

Helpful resources

Announcements
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.

Top Solution Authors