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
Anonymous
Not applicable

Sum measure values from specific table

Hello all,

I have got a problem. I wrote a measure using 3 different tables to predict costs for products in future.

My measure uses about 5 calculate functions with allexcepts and distinct countrows and filters and so on, so i can not just sum it up so easily. My question is, if i have table, where i have all data needed to make my measure work, can i simply take that cell from table?

 

01102018 screen table sum problem2.png

8 REPLIES 8
v-lili6-msft
Community Support
Community Support

hi, @Anonymous

     You can get it, but you need to use VAR Function to create a dynamic table firstly.

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hello, @v-lili6-msft

I am intrested, can you help me with creating that table? And will it be slower or faster?

Thank you for sharing the idea

Best Regards

Radkos

hi, @Anonymous

     This requires specific data and requirements to be analyzed. this case can help you understand it.

https://community.powerbi.com/t5/Desktop/Group-Measure-values-on-rows/m-p/514475#M240454

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hello again @v-lili6-msft

Thank you for your help.

I read the topic, that you sugested. If I get it right you want to group my data in some way to make it easier to calculate, but I dont really know how to do it. Maybe i will show you how my dataset is made and how does my measure work, so you will have better understanding for my problem.

First I had a table, that had distinct values of 2 columns - material number in first column and company code in second.

Every row had unique connection of company code and material number, and a third column of prize.

Then I expanded my table -> for every row i added a columns with grouping data alike brand or type, but also every row I expanded for few attributes(freshness of material) with max of 21 rows (0,5,10,15,...,100) and a value of quantity in that freshness category.

Third step was merging this table with another table with had the same material/company code but also it has a demand for every week in horizon(78weeks from now) and a value of it. So every row that had material/companycode combo with freshness and value was multiplied up to 78 times because of the demand column.

My measure takes freshnes of aging stock dynamically (lets take 60 - 80) and sums up quantity of aging stock. Then it takes dynamically chosen number of weeks (lets take 10) and for every companycode/material it sums up demand value. If we have more aging stock then demand we will probobaly wont sell it and it will get old, so we lost money, and for every material/companycode that has more aging stock than demand we multiply by price. And that what my measure do and i want to sum it up somehow.

Below I put my measure in better view.

 

Bad Goods Projected = [BG Projected]*CALCULATE(SUM('Merge1'[Price]), ALLEXCEPT('Merge1','Merge1'[Material],'Merge1'[Company code]),'Merge1'[Plant])/CALCULATE(COUNTROWS('Merge1'),ALLEXCEPT('Merge1','Merge1'[Material],'Merge1'[Company code],'Merge1'[Plant]))

 

BG Projected = IF([Aging Stock]-[Demand]<0,0,[Aging Stock]-[Demand])

 

Aging Stock = CALCULATE(SUM('Merge1'[FreshNes of Inventory.Value]),ALLEXCEPT('Merge1','Merge1'[Material],'Merge1'[Company code],'Merge1'[Plant],'Merge1'[FreshNes of Inventory.Attribute2]),FILTER('Merge1','Merge1'[FreshNes of Inventory.Attribute2]>=[Min Aging Value]),FILTER('Merge1','Merge1'[FreshNes of Inventory.Attribute2]<[Max Aging Value]))/CALCULATE(COUNTROWS('Merge1'),ALLEXCEPT('Merge1','Merge1'[Material],'Merge1'[Company code],'Merge1'[Plant],'Merge1'[FreshNes of Inventory.Attribute2]),FILTER('Merge1','Merge1'[FreshNes of Inventory.Attribute2]>=[Min Aging Value]),FILTER('Merge1','Merge1'[FreshNes of Inventory.Attribute2]<[Max Aging Value]))*CALCULATE(DISTINCTCOUNT('Merge1'[FreshNes of Inventory.Attribute2]),ALLEXCEPT('Merge1','Merge1'[Material],'Merge1'[Company code],'Merge1'[Plant]),FILTER('Merge1','Merge1'[FreshNes of Inventory.Attribute2]>=[Min Aging Value]),FILTER('Merge1','Merge1'[FreshNes of Inventory.Attribute2]<[Max Aging Value]))

 

Demand = CALCULATE(SUM('Merge1'[Stock Location - Demand.Value]),ALLEXCEPT('Merge1','Merge1'[Material],'Merge1'[Company code],'Merge1'[Plant]),FILTER('Merge1','Merge1'[Stock Location - Demand.Week]<=[ActWeek]+[LAG]))/3

 

My question is does that makes sense to you and do you think i could do it faster/better/other way so i can calculate sum of this

Thank you once again

Best Regards

Radkos

hi, @Anonymous

I'm a little confused about your description, could you please do and share a simple sample pbix and expected output for us.

You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading.

 

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-lili6-msft

 

I am sorry for the delay, but i prepared raw data with this function for you to look up.

 

https://nestle-my.sharepoint.com/:u:/r/personal/michal_radkowski_cppl_nestle_com/Documents/Bad%20Goo...

 

If you know how to do it faster/better or how to sum it up please let me know.

Thank you in advance

Radkos

hi, @Anonymous

   I can't access your link, could you please share your sample pbix to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading.

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hello again,  @v-lili6-msft

https://www.dropbox.com/s/ik8sr8id8lkcspl/Bad%20Goods%20TEST.pbix?dl=0

I have a problem with sending this by dropbox, maybe this is a good link

Best Regards

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.