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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Calculating values based on different sum of monthly values

Hi Community,

I have two sales tables: Invoices and ERP Invoices. They are coming from different sources and there is a table called center which holds the data of the company centers which manage the sales and a table called dates which is the calendar table. There are multiple fields in all 3 tables but I give some examples to make it easier to get to the problem:

Invoices and Invoices ERP are almost the same:

 

Date IDItemInvoice Amount Center ID...
237348Part3432200002331 
237454Part222325002443 

 

the Center:

Center IDCenter nameProduct group...
2331Kiev 233Sweets 
2332Rome 11Bread 

 

and the date:

Date IDDateYearFiscal Month...
2373482023-08-1520238 
2373492023-08-1620238 

 

The Sales tables, centers and Time are all having a defined relationship and work good.

 

The values coming from the different sales sources can sometimes be updated differently in the two tables. We have 2 calculated measures [Sales] and [ERP Sales] which calculates the amount of sales from the respeceted tables.

 

Now I want to create a new measure and calculate the sale amounts like this: if the [Sales] is blank in a whole fiscal month give me [ERP Sales] and if not, give the [Sales]. This should not consider the values of Product group or centers. What I mean is that the [Sales] for a special product group can be null in a month but other products can have value which matters. same goes for centers. so the result I want is like these two tables below:

Fiscal MonthSalesERP SalesNew measure
1200010002000
2250030002500
3 35003500
Total450075008000

 

Fiscal MonthProduct groupSalesERP SalesNew measure 
1sweets750750750 
1breads1000 1000 
1dairy250250250 
2sweets200010002000 
2breads5001500500 
2Batteries 500  
3sweets 700700 
3breads 18001800 
3dairy 10001000 
Total 450075008000 

 

As shown in the first table the new measure is bringing in the Sales for Fiscal month 1 and 2 since there is a value there for it but for  Fiscal month 3 it brings in the ERP Sales. in the second table it works the same based on month, and it does not consider the product group cases. (see that for batteries although there is no sales for it, it will not bring the ERP Sales because there are other values in the month 2 for Sales). I tried the below measures but it gives wrong  total:

1)

Has Sales =
VAR SelectedMonth = SELECTEDVALUE(Date[Fiscal Month])
VAR SalesSum = CALCULATE([Invoices ], ALL('Center'[Product Group]),'Date'[Fiscal Month] = SelectedMonth)
RETURN SalesSum > 0
 
------
2)
Sales 2 = if([Has Sales],[Sales],[Sales ERP])
 
The total number is wrong and is showing the Sales ERP total. When I put the [Has Sales] measure into the table, it shows false for the Total row. What should I do? 

 

 

1 REPLY 1
lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely. Leave out anything not related to the issue.
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.