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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.