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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Luca2020
Helper I
Helper I

Summarize problem

Hi, 

I've a table with the value of each costumer's order, an order may be divided in additional sub-orders or item according to the type of service required. All items from an order may have the same code like 1 for the 11234 order, or multiple codes like 1, 2, 3 for the 11234 order depending on the supplyer which can be the same or not. In any case each item code is unique to the order so, knowing the item code you can always recognize the order number.  

 

In addition to the revenue, I've also a table with the associated expected costs for each items, constantly updated, and a table with the actual costs which is updated monthly. 

 

Table1.png

 

What I would like to obtain, is a new table which uses the summarize function to summarize, for each order, the actual cost but since this table is uptaded less frequently, I'd also like to see the budget cost in the meantime:

 

SUMMARIZE('Actual Cost', 'Actual Cost [Order], "Direct Cost", IF(SUM('Actual Cost' [Amount]) = BLANK() || SUM(SUM('Actual Cost' [Amount]) <  SUM('Cost Budget'[Amount]), SUM('Cost Budget'[Amount]) ,(SUM('Actual Cost' [Amount])))

 

The actual costs are always equal or higher than the expected ones because the budget is from the order confirmation to the supplier while the actual cost is from the purchase invoice which may have additional costs for certificates, assurance, customs duty. 

 

My problem is that when I'tried that formula, the amount from the actual is correct while the budget is three times the real one, like Bi multiplies the value by the numbers of row, since the order is one but the item rows are three. Maybe is because the budget has items and the actual cost table has N. of Order. 

 

I cannot use the RELATED function to create a new column with the order numbers in the budget table because of the many to many relationships. 

 

Can someone help? 

 

Thanks!

 

1 ACCEPTED SOLUTION
DavisBI
Solution Specialist
Solution Specialist

Hi, @Luca2020 ,

 

I suggest that you provide the model relationship of different tables, one to many or many to one, which is helpful to solve this problem. 



Nevertheless, I have encountered similar problem before.

My solution is to create a new calculation column in the many-end table to calculate the number of rows that will be repeated after use RELATED() from one-end table, and then your measure can be divided by the value in this column to get a value that won't be repeated.

The formula for this calculate column is :

column = countrows(RELATEDTABLE(<your main table>))

You can also refer to this article.

 

 Mark this post as solution if this helps, thanks!

View solution in original post

1 REPLY 1
DavisBI
Solution Specialist
Solution Specialist

Hi, @Luca2020 ,

 

I suggest that you provide the model relationship of different tables, one to many or many to one, which is helpful to solve this problem. 



Nevertheless, I have encountered similar problem before.

My solution is to create a new calculation column in the many-end table to calculate the number of rows that will be repeated after use RELATED() from one-end table, and then your measure can be divided by the value in this column to get a value that won't be repeated.

The formula for this calculate column is :

column = countrows(RELATEDTABLE(<your main table>))

You can also refer to this article.

 

 Mark this post as solution if this helps, thanks!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.