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

Sorting SUM to match an ID, multiply by value attached.

Hello everyone, I am pretty new to power BI.

 

My challenge today is to get an added weight sold of different products, each with a different weight. I have a sales table where one of the columns is the quantity sold in one single sale (linked to a single product), which I have to compile for a determinated time frame to get the number of products sold. Then I multiply that number to the weight attached to the product in another table.

 

I was able to pull off doing this a product at a time (pretty simple really), but my objective is to add however many as I want at the same time, each one having its own correct sales-weight relation.

 

I have tried multiple things but I cannot seem to get it right.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Can you share sample data and sample output?

 

But a few solutions which can help you without going into the details. get weight into sales table as a new column and use it. Or have a measure based on a common dimension.

new column in sales = sumx(filter(weight[product]=sales[product]),weight[weight])
new column in sales = maxx(filter(weight[product]=sales[product]),weight[weight])

Measure = sumx(summarize('product dim','product dim'[product], "_qty",sales[qty],"_wt",sum(weight[weight])),[_qty]*[_wt])

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin

G

 

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

Can you share sample data and sample output?

 

But a few solutions which can help you without going into the details. get weight into sales table as a new column and use it. Or have a measure based on a common dimension.

new column in sales = sumx(filter(weight[product]=sales[product]),weight[weight])
new column in sales = maxx(filter(weight[product]=sales[product]),weight[weight])

Measure = sumx(summarize('product dim','product dim'[product], "_qty",sales[qty],"_wt",sum(weight[weight])),[_qty]*[_wt])

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin

G

 

Thank you @amitchandak and everyone for your replies.

So each of the Sales table rows is an individual sale, each with its own quantity of products sold. I could make a calculated column to just have the weight of each sale in every row, which would most likely work. I haven't really worked with columns before, I'm trying to do Sales[units] * RELATED(Products_Weight[unitWeight]) but nothing really happened. The Sales and Products_Weight tables aren't directly related, they have another Dim_Products table in between, don't know if that is the problem.

Ok, nevermind. Adding the weight of each sale to the Sales table actually worked, thank you very much, cheers!

bfernandez
Resolver II
Resolver II

Hey @ezedayplas 

 

Can you provide screenshots and what your expected outcome should be?

smpa01
Super User
Super User

@ezedayplas  would help if you can share some sample data (which can be copy pasted in excel) representative of your problem with the desired outcome clearly shown

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

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.