Forum Discussion
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:
- Anonymous2 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
- AnonymousNot 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.- gbarr12345Post Prodigy
That works! Thank you so much!
- Ritaf1983Super User
Hi gbarr12345
Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.
How to Get Your Question Answered Quickly