Forum Discussion

vinny1986's avatar
vinny1986
Icon for Helper I rankHelper I
4 years ago
Solved

Removing column filter context from a measure for a variation

Hello,   I'm trying to do variation between an actual and budget in column format with years. It should look like this:     Type Actual Budget   Year 2021 2022 2022 Section Categ...
  • v-kkf-msft's avatar
    v-kkf-msft
    4 years ago

    Hi vinny1986 ,

     

    Please try the following formula:

     

    Variation = 
    VAR __Year =
        CALCULATE (
            MAX ( dbo_DimTemps[AnneeFinanciere] ),
            ALLSELECTED ( dbo_DimTemps[AnneeFinanciere] )
        ) --to select the max year from my filter--
    VAR __Actual =
        CALCULATE (
            [Année],
            FILTER (
                ALLSELECTED ( PV_FactSoldesGL_pourfusion[Type] ),
                PV_FactSoldesGL_pourfusion[Type] = "Actuel"
            ),
            dbo_DimTemps[AnneeFinanciere] = __Year
        ) --to select the actual from current year (2022)--
    RETURN
        IF (
            SELECTEDVALUE ( PV_FactSoldesGL_pourfusion[Type] ) = "Budget"
                && ISBLANK ( SELECTEDVALUE ( dbo_DimTemps[AnneeFinanciere] ) ) = FALSE,
            __Actual - [Année]
        )

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.