Forum Discussion
Circular Dependency Error in Power BI Measure
- 1 year ago
Hi Mastermayank26 i tried implementing this, almost there.... I guess the issue might be in the last section where it calculates the forecasted sales after the last sales month. Could you take a look?
Forecast Sales =VAR CurrentMonth = MAX('Date'[Date])-- Get previous month's start and end datesVAR PrevMonthStart =DATE(YEAR(CurrentMonth), MONTH(CurrentMonth) - 1, 1)VAR PrevMonthEnd =EOMONTH(PrevMonthStart, 0)-- Calculate Total Sales for the previous monthVAR PrevMonthSales =CALCULATE([Total Sales],FILTER(ALL('Date'),'Date'[Date] >= PrevMonthStart && 'Date'[Date] <= PrevMonthEnd))-- Get the last month of actual sales dataVAR LastSalesMonth =CALCULATE(MAX('Date'[Date]),FILTER(ALL('Date'),[Total Sales] > 0))VAR MonthsAhead =DATEDIFF(LastSalesMonth, CurrentMonth, MONTH)RETURNIF (ISBLANK(PrevMonthSales) && MonthsAhead > 0,PrevMonthSales + 100 * MonthsAhead ,PrevMonthSales)
Hi Mastermayank26 i tried implementing this, almost there.... I guess the issue might be in the last section where it calculates the forecasted sales after the last sales month. Could you take a look?
Hi techies
The example i gave in the questions is just for reference, I want to calculate Total Sales recursively for next 4-6 months. Do you know how to calculate it recursively?
E.g I have data till March 2025 then it will show actual sales
March Sales =100
April it will show Sales = Actual Sales +Previous Month sales
May Sales would be =Actual Sales + Previous Month sales
- techies1 year ago
Super User
ok, this is tricky