Forum Discussion

BGB's avatar
BGB
Icon for Helper II rankHelper II
4 years ago
Solved

Current Month Day No Forecast

Hi All,

 

I'm doing forecast figures for some projects and I have been asked that in the current month (in this case March 2022) when the date is below the 15th the forecast figure should be Previous Month Actual Cost, when equal to or above 15th of this current month it returns Actual Cost for March 2022, April onward display budget figure.

In the picture below, Actual and Forecast is the column/measure that needs changing. I have added Budget and Actual Cost in Variance measure to derive Actual and Forecast column, however, March shows 618 but should be 200 (Previous month actual cost) until its 15th of March then shows 485.. April going forward has the correct figure as they are.

 

Thanks in advance.

  • How about now? Tomorrow it will be 485 😁

     

     

    Measure = 
    
    SWITCH
    	(
    		TRUE(),
    		AND
    			(
                    
    				SELECTEDVALUE('Date'[Month_no]) < MONTH(TODAY()), 
    				SELECTEDVALUE('Date'[Year]) <= YEAR(TODAY())
    			),
            SUM('Budget Actual'[Actual Cost]), --Before Active Month
    		AND
    			(
                    
    				SELECTEDVALUE('Date'[Month_no]) > MONTH(TODAY()), 
    				SELECTEDVALUE('Date'[Year]) >= YEAR(TODAY())
    			),
    		[Actual and forecast], --After Active Month
    		TODAY () < 
    			DATE
    				(
    					YEAR(TODAY()),
    					MONTH(TODAY()),
    					15
    				),
    		[Actual and Forecast PM], -- Active Month, Before 15
    		SUM('Budget Actual'[Actual Cost]) -- Active Month, After 15
    	)

     

10 Replies

  • Hi BGB ,

     

    Can you try this please? 🙂

     

    SWITCH
    	(
    		TRUE(),
    		TODAY <= 
    			DATE
    				(
    					15,
    					MONTH(TODAY()),
    					YEAR(TODAY())
    				),
    		previous_month,
    		actual_forecast
    	)
    • coskuersanli's avatar
      coskuersanli
      Icon for Resolver III rankResolver III

      I've changed it a little, this should work.

       

      SWITCH
      	(
      		TRUE(),
      		AND
      			(
      				MONTH(dates_table[date]) > MONTH(TODAY()), 
      				YEAR(dates_table[date]) > YEAR(TODAY())
      			),
      		budget, 
      		TODAY <= 
      			DATE
      				(
      					15,
      					MONTH(TODAY()),
      					YEAR(TODAY())
      				),
      		previous_month,
      		actual_forecast
      	)

       

       

      • BGB's avatar
        BGB
        Icon for Helper II rankHelper II

        coskuersanli Thanks for looking at this.
        When I tried this in a measure it won't accept 'Date'[date] and when I tried to use it as a column it didn't accept today
        line 7..

         

         

         

    • coskuersanli's avatar
      coskuersanli
      Icon for Resolver III rankResolver III

      I think we've done it this time 🙂

       

      I've added a month column to Date table with MONTH(Date[Date]) and changed the measure a little. (DATE function was wrong.)

      Measure = 
      
      SWITCH
      	(
      		TRUE(),
      		AND
      			(
                      
      				SELECTEDVALUE('Date'[Month_no]) > MONTH(TODAY()), 
      				SELECTEDVALUE('Date'[Year]) >= YEAR(TODAY())
      			),
      		[Actual and forecast], 
      		TODAY () <= 
      			DATE
      				(
      					YEAR(TODAY()),
      					MONTH(TODAY()),
      					15
      				),
      		[Actual and Forecast PM],
      		[Actual and Forecast]
      	)

       

       

  • coskuersanli I think we are sooo close! However, Feb and March should have the same number now (200) until its 15th of March then march changes to March Actual which is 485. It's a very tricky one.
    Only the current month picks the Previous Month's value when it's not yet the 15th of the month. Past months should have Actuals for the month and future month have forecast (we have no problem with forecast at the moment).
    Thanks so far. 


    • coskuersanli's avatar
      coskuersanli
      Icon for Resolver III rankResolver III

      How about now? Tomorrow it will be 485 😁

       

       

      Measure = 
      
      SWITCH
      	(
      		TRUE(),
      		AND
      			(
                      
      				SELECTEDVALUE('Date'[Month_no]) < MONTH(TODAY()), 
      				SELECTEDVALUE('Date'[Year]) <= YEAR(TODAY())
      			),
              SUM('Budget Actual'[Actual Cost]), --Before Active Month
      		AND
      			(
                      
      				SELECTEDVALUE('Date'[Month_no]) > MONTH(TODAY()), 
      				SELECTEDVALUE('Date'[Year]) >= YEAR(TODAY())
      			),
      		[Actual and forecast], --After Active Month
      		TODAY () < 
      			DATE
      				(
      					YEAR(TODAY()),
      					MONTH(TODAY()),
      					15
      				),
      		[Actual and Forecast PM], -- Active Month, Before 15
      		SUM('Budget Actual'[Actual Cost]) -- Active Month, After 15
      	)

       

      • BGB's avatar
        BGB
        Icon for Helper II rankHelper II

        coskuersanli Thank you so so much. It worked! I have to change my Month No to wholenumber instead of text then Boom!