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
Gugge
Helper I
Helper I

Same formula acting different in two reports

Hi,

I'm stuck with a problem I cant solve. I have two reports used for sales reporting for various reasons. The data I'm extracting from NAV is from the same server. The data where I have the issue is extracting a table in NAV that's summarizing Orders and Territory on a daily basis. In PowerBI I'm consolidating this data with other sales data to build a complete revenue table. Both reports has the same formula to calculate difference between two rows based on date value and territory, for example the value today would be Xterritory TodayOrder minus XterritoryYesterday orders. There are a few gaps in the dates where the NAV report hasn't been ran, which causes an issue.

I'm using the formulas below. In my WorldSales report, the formula works as supposed even when there is a gap between the dates. In my US Sales report it only works when the date is the previous date. I've extracted some examples below to show the error, in world sales I'm getting sales numbers on all rows except the first one (which is ok), but in US I'm not getting data when the gap is more than two days. It is working between May 21 and May 19, but not May 19 and May 12.

 

Is there a setting somewhere I'm missing on how dates work, or where do I go wrong?

 

 

 

_____World sales_____
ChangeOpenOrders =
VAR __date = 'NAV_SalesDataConsolidated'[posting_Date]
VAR __filterTable = ALLEXCEPT( 'NAV_SalesDataConsolidated', 'NAV_SalesDataConsolidated'[TerritoryCode])
VAR __previousDate =
CALCULATE(
MAX( 'NAV_SalesDataConsolidated'[posting_Date] ),
__filterTable,
'NAV_SalesDataConsolidated'[Posting_Date] < __date
)
VAR __previousAmt =
CALCULATE(
SUM('NAV_SalesDataConsolidated'[Total_Open_Orders_$] ),
__filterTable,
'NAV_SalesDataConsolidated'[Posting_Date] = __previousDate
)
RETURN IF( NOT ISBLANK( __previousAmt ), 'NAV_SalesDataConsolidated'[Total_Open_Orders_$] - __previousAmt )

 

 

 

_____US SALES_____
ChangeOpenOrders =
VAR __date = 'TotalSales'[posting_Date]
VAR __filterTable = ALLEXCEPT( 'TotalSales', 'TotalSales'[INVCTerritoryCode])
VAR __previousDate =
CALCULATE(
MAX( 'TotalSales'[posting_Date] ),
__filterTable,
'TotalSales'[Posting_Date] < __date
)
VAR __previousAmt =
CALCULATE(
SUM('TotalSales'[Total_Open_Orders] ),
__filterTable,
'TotalSales'[Posting_Date] = __previousDate
)
RETURN IF( NOT ISBLANK( __previousAmt ), 'TotalSales'[Total_Open_Orders] - __previousAmt )

 

 

 

Worlds sales data (I removed dates between 2021 and 2023)

Posting_DateDescriptionProductSales_USDTotal_Open_Orders_$ChangeOpenOrdersTerritoryCode
2020-12-31OpenOrdersOpenOrders 258 688 XYZ
2021-03-31OpenOrdersOpenOrders36 313295 00036 313XYZ
2021-05-31OpenOrdersOpenOrders-164 406130 594-164 406XYZ
2021-06-16OpenOrdersOpenOrders234 700365 294234 700XYZ
2021-06-17OpenOrdersOpenOrders75 950441 24475 950XYZ
2021-06-18OpenOrdersOpenOrders-60 000381 244-60 000XYZ
2023-05-12OpenOrdersOpenOrders59 188403 37559 188XYZ
2023-05-19OpenOrdersOpenOrders52 850456 22552 850XYZ
2023-05-21OpenOrdersOpenOrders32 500488 72532 500XYZ

 

US Sales (I removed dates between 2021 and 2023)

NoDescriptionPosting_DateINVCTerritoryCodeChangeOpenOrdersTotal_Open_OrdersSalesAmount
OpenOrdersOpenOrders2020-12-31XYZ 258 688 
OpenOrdersOpenOrders2021-03-31XYZ 295 000 
OpenOrdersOpenOrders2021-05-31XYZ 130 594 
OpenOrdersOpenOrders2021-06-16XYZ 365 294 
OpenOrdersOpenOrders2021-06-17XYZ75 950441 24475 950
OpenOrdersOpenOrders2021-06-18XYZ-60 000381 244-60 000
OpenOrdersOpenOrders2023-05-12XYZ59 188403 37559 188
OpenOrdersOpenOrders2023-05-19XYZ 456 225 
OpenOrdersOpenOrders2023-05-21XYZ32 500488 72532 500

 

2 REPLIES 2
Idrissshatila
Super User
Super User

Hello @Gugge ,

 

check if there's any filter that is affecting the report or the chart.

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Hi,

This is a column I've added to the sales table to calculate the change, so there are no filters on the report or chart that should effect the calculation.

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.