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
larbond
Frequent Visitor

Forecast the sales revenue over time based on start and end date

I try to forecast the sales revenue over time. I made some progress, but the graph shows an incorrect values.  The graph shows a value of 10,99, but the total amount of January should be 340. In case of Sales ID I expect January 340 Februari. 

Repport.png

 

 

 

I have the following tables:  

  • Date
  • Services

The table Dates contains the following columns

  • Date (all dates from 1-1-2017 till 1-1-2019)
  • Calculatedaterevenue
  • Measure (calculation see below)

 

The table Services contains the following columns

Services.png

 

Calculations

Measure = 
	CALCULATE(SUM(Services[RevenuePerBillingDay]);
		FILTER(Services;
			COUNTROWS(
				FILTER(
					VALUES(CalendarDate[Date]);
			            Services[StartDate]<=CalendarDate[Date] &&
			            Services[EndDate]>=CalendarDate[Date])
			)>0
			)
		)
BillDays = CALCULATE(
	COUNT(CalendarDate[Date]);
	DATESBETWEEN(CalendarDate[Date];Services[StartDate];Services[EndDate]))
RevenuePerBillingDay = Services[Revenue]/Services[BillDays]

 

2 ACCEPTED SOLUTIONS
v-shex-msft
Community Support
Community Support

Hi @larbond,

 

You can try to use below formula to get the summary daily payment:

 

Total = 
VAR current_id =
    MAX ( Records[ID] )
VAR current_date =
    MAX ( 'Calendar'[Date] )
VAR curretn_Pay =
    CALCULATE (
        MIN ( Records[PerDay] ),
        FILTER (
            ALL ( Records ),
            current_date IN CALENDAR ( [StartDate], [EndDate] )
                && [ID] = MAX ( Records[ID] )
        )
    )
RETURN
    curretn_Pay * COUNT ( 'Calendar'[Date] )

9.PNG

 

Notice: my formula only works when you limit date range to specific  year, if you not choose the specific year, it will return wrong result.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @larbond,

 

You can try to use below formula to get the summary daily payment:

 

Total = 
VAR current_id =
    MAX ( Records[ID] )
VAR current_date =
    MAX ( 'Calendar'[Date] )
VAR curretn_Pay =
    CALCULATE (
        MIN ( Records[PerDay] ),
        FILTER (
            ALL ( Records ),
            current_date IN CALENDAR ( [StartDate], [EndDate] )
                && [ID] = MAX ( Records[ID] )
        )
    )
RETURN
    curretn_Pay * COUNT ( 'Calendar'[Date] )

9.PNG

 

Notice: my formula only works when you limit date range to specific  year, if you not choose the specific year, it will return wrong result.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Finnaly, it works with an example of SQLBI.

 

https://www.sqlbi.com/articles/analyzing-events-with-a-duration-in-dax/

 

 

 

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.