Forum Discussion

gbarr12345's avatar
gbarr12345
Post Prodigy
2 years ago
Solved

Percentage difference measure

Hi,

 

I have a measure to get the percentage difference for year 1 between depletion and exports.

 

I'm looking to have this measure to do the percentage difference for year 2, year 3 and year 4 also in the one code.

 

Please find my measure below:

 

Year 1 % difference =
VAR Dep = [Depletion First 12 Months]
VAR Exports = [USA Exports First 12 Months]
RETURN
IF(
    Exports <> 0,
    DIVIDE(Dep, Exports, 0),
    BLANK()
)
 
The measure works for year 1 but when I change the year to year 2, 3 or 4 the card percentage doesn't change.
 
See images below.
 
Can anyone help me update my measure to make this work please?
 
Any help would be greatly appreciated! 
 

 

 

 

 

 

 

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi gbarr12345 ,

    Ritaf1983 Thanks for your concern about this case!
    And gbarr12345 , the problem should be with these two measures of yours:


    Here I build a sample data myself:

    Measures:

    Depletion First 12 Months = 
    CALCULATE(
        SUM('Table'[Depletion]),
        ALL('Table'),
        MONTH('Table'[Date]) >= 1 && MONTH('Table'[Date]) <= 12 && 'Table'[Year] IN VALUES('Table'[Year])
    )
    Exports First 12 Months = 
    CALCULATE(
        SUM('Table'[Exports]),
        ALL('Table'),
        MONTH('Table'[Date]) >= 1 && MONTH('Table'[Date]) <= 12 && 'Table'[Year] IN VALUES('Table'[Year])
    )
    Year 1 % difference = 
    VAR Dep = [Depletion First 12 Months]
    VAR Exports = [Exports First 12 Months]
    RETURN
    IF(
        Exports <> 0,
        DIVIDE(Dep, Exports, 0),
        BLANK()
    )

    And the final output is as below:



     

    If there is still a problem, could you please provide your sample data, and the DAX you created for these two measures, please!

    Best Regards,
    Dino Tao
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi gbarr12345 ,

    Ritaf1983 Thanks for your concern about this case!
    And gbarr12345 , the problem should be with these two measures of yours:


    Here I build a sample data myself:

    Measures:

    Depletion First 12 Months = 
    CALCULATE(
        SUM('Table'[Depletion]),
        ALL('Table'),
        MONTH('Table'[Date]) >= 1 && MONTH('Table'[Date]) <= 12 && 'Table'[Year] IN VALUES('Table'[Year])
    )
    Exports First 12 Months = 
    CALCULATE(
        SUM('Table'[Exports]),
        ALL('Table'),
        MONTH('Table'[Date]) >= 1 && MONTH('Table'[Date]) <= 12 && 'Table'[Year] IN VALUES('Table'[Year])
    )
    Year 1 % difference = 
    VAR Dep = [Depletion First 12 Months]
    VAR Exports = [Exports First 12 Months]
    RETURN
    IF(
        Exports <> 0,
        DIVIDE(Dep, Exports, 0),
        BLANK()
    )

    And the final output is as below:



     

    If there is still a problem, could you please provide your sample data, and the DAX you created for these two measures, please!

    Best Regards,
    Dino Tao
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.