Forum Discussion

LuisCaston82's avatar
LuisCaston82
New Member
2 years ago
Solved

Switch and add a result

Dear all,

I've this formula:

Actual YTD + Forecast =

var _YTD = CALCULATE([Amount], BIFRF000[Report] = "", BIFRF000[Period Type] = "T", BIFRF000[Type] = "V")
var _Forecast = CALCULATE([Amount], BIFRF000[Report Type] = "T")

RETURN
 
SWITCH(
    TRUE,
    _YTD = "", _YTD,
    _YTD <> "", _Forecast)

The goal is like this:

November and december is blank so is applying forecast, is correct.
Junuaty to October is real but is summing Actual + Forecast and is not correct, must be only real because _YTD has result.

Do you know how can I do it?




  • LuisCaston82 

    Please try this measure:

    Actual YTD + Forecast =
    VAR _YTD =
        CALCULATE (
            [Amount],
            BIFRF000[Report] = "",
            BIFRF000[Period Type] = "T",
            BIFRF000[Type] = "V"
        )
    VAR _Forecast =
        CALCULATE ( [Amount], BIFRF000[Report Type] = "T" )
    RETURN
        IF ( _YTD = 0, _Forecast, _YTD )

2 Replies

  • LuisCaston82 

    Please try this measure:

    Actual YTD + Forecast =
    VAR _YTD =
        CALCULATE (
            [Amount],
            BIFRF000[Report] = "",
            BIFRF000[Period Type] = "T",
            BIFRF000[Type] = "V"
        )
    VAR _Forecast =
        CALCULATE ( [Amount], BIFRF000[Report Type] = "T" )
    RETURN
        IF ( _YTD = 0, _Forecast, _YTD )
  • Awersome @Fowmy !!
    Thank you so much! Works perfectly.

    One doubt more Fowmy : Do you know why the total doesn´t sum the real?

     

    Total sum is: 60.350.227 not 51.951.034.