Forum Discussion

4thSun's avatar
4thSun
Frequent Visitor
1 year ago
Solved

SWITCH function in measure returns wrong value in YTD calculation group

As a follow-up to my previous question which Angith_Nair  promptly responded to: https://community.fabric.microsoft.com/t5/Desktop/Financial-reporting-Budget-3-9-forecast-6-6-forecast-and-9-3/m-p/4...
  • MFelix's avatar
    MFelix
    1 year ago

    Hi Anonymous ,

     

    I have done the following:

    • Created a new column on the Wins forecast table:
    Category Adjusted = 
            var _Category  = SWITCH(
                                TRUE(),
                                MONTH([date_month]) <= 6 && MONTH([date_month]) > 3, "BUD",
                                MONTH([date_month]) <= 9 && MONTH([date_month]) > 6, "3+9",
                                MONTH([date_month]) <= 12 && MONTH([date_month]) > 9, "6+6"
                            )
        RETURN
            IF (_Category = 'Wins forecast'[category], _Category)

    Add this new measure:

    Wins FC NEW MEASURE = 
    CALCULATE(SUM('Wins forecast'[wins]),'Wins forecast'[Category Adjusted] <> "") 

     

    This will allow to have the calculation of the forecast without the need for the switch measure, you can see that the result will be correct based on the selection:

     

    See file attach.

     

    This setup forces the values to show up only for the specific moths were each forecast is used and not on the rest of the year where the values are for budget or for other forecast.

     

    I did the new column in DAX but you can also do it in M Query that is more advisable.

  • 4thSun's avatar
    4thSun
    1 year ago

    MFelixyes, that's correct!

    I have changed the VAR currentmonth to month(max(Dim_date[Date])) instead of month(selectedvalue (Dim_date[Date])) and it seems to be working as should. I'd need to test it out to make sure and let you know.