cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lancea
Helper I
Helper I

Calculate an Estimated YTD Total with a static Measure

Considering I have the following table:

 

DateSalesYTD SalesStatic Estimate for Sales
Jan-202110001000500
Feb-202120003000500
Mar-202110004000500
Apr-202115005500500
May-202115007000500
Jun-2021 7500500
Jul-2021 8000500
Aug-2021 8500500
Sep-2021 9000500

 

How do I go about creating a measure or calculated column for the YTD Sales column? The formula is YTD, but if there is no value for the current month, then add the Static Estimate value instead (to show something like a forecast).

1 ACCEPTED SOLUTION

Hi, @lancea ;

You could try to delete the .date in the picture, if it doesn’t work, you can just copy my code and change the key field

v-yalanwu-msft_0-1623405116483.png

The final output is shown below: 

v-yalanwu-msft_1-1623405214066.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @lancea ;

You could create a measure by the following formula:

YTD Sales1 =
VAR _sale =
    CALCULATE ( SUM ( [Sales] ), DATESYTD ( 'Table'[Date], "12/31" ) )
VAR _static =
    CALCULATE (
        SUM ( [Static Estimate for Sales] ),
        DATESYTD ( 'Table'[Date], "12/31" ),
        FILTER ( ALL ( 'Table' ), [Sales] = BLANK () )
    )
RETURN
    IF ( MAX ( [Sales] ) = BLANK (), _static + _sale, _sale )

Or you could create a column:

YTD Sales2 =
VAR _sales =
    CALCULATE (
        SUM ( [Sales] ),
        DATESYTD ( 'Table'[Date], "12/31" ),
        ALL ( 'Table' )
    )
VAR _static =
    CALCULATE (
        SUM ( [Static Estimate for Sales] ),
        DATESYTD ( 'Table'[Date], "12/31" ),
        FILTER ( ALL ( 'Table' ), [Sales] = BLANK () )
    )
RETURN
    IF ( [Sales] = BLANK (), _sales + _static, _sales )

The final output is shown below:  

 v-yalanwu-msft_0-1623376444395.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello,

 

Unfortunately, I am getting the incorrect result as shown below:

 

YTD Sales1 =
VAR _sale =
CALCULATE ( SUM ( [Sales] ), DATESYTD ( Sheet1[Date Description].[Date], "12/31" ) )
VAR _static =
CALCULATE (
SUM ( Sheet1[static] ),
DATESYTD ( Sheet1[Date Description].[Date], "12/31" ),
FILTER ( ALL ( Sheet1 ), [Sales] = BLANK () )
)
RETURN
IF ( SUM ( [Sales] ) = 0, _static + _sale, _sale )

 

lancea_0-1623398562030.png

 

Please note that static column in my case is a CalculatedColumn with a flat value of 75 (static = 75). And here is my dataset (for some reason, it won't allow me to post table):

 

lancea_0-1623399241664.png

Can you please let me know what I am doing wrong?

Hi, @lancea ;

You could try to delete the .date in the picture, if it doesn’t work, you can just copy my code and change the key field

v-yalanwu-msft_0-1623405116483.png

The final output is shown below: 

v-yalanwu-msft_1-1623405214066.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

amitchandak
Super User IV
Super User IV

@lancea , Try a measure like this with help from date table

 

YTD Sales = CALCULATE(SUMX(values(Date[Month Year]) , calculate(if isblank(sum(Sales[Sales])) , sum(Table[Static Estimate]), sum(sales[Sales]))),DATESYTD('Date'[Date],"12/31"))



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Top Solution Authors
Top Kudoed Authors