Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am quite new to Power BI world. I am trying to calculate and show the percentage growth for a column data. Let me illustrate:
Product Year Volume
Product 1 1/1/2019 10
Product 1 1/1/2020 15
Product 1 1/1/2021 20
Product 2 1/1/2019 35
Product 2 1/1/2020 40
Product 2 1/1/2021 45
I am trying to display the percentage growth between the 2019 and 2021 in a Card which will be unaffected even if I select any year for any other visual
Solved! Go to Solution.
Sorry, I'm assuming that you are using the auto-datetime hierarchy feature for the slicer. I don't normally use these myself. The following variation should fix this issue.
Growth = var volume2021 = CALCULATE(sum('Table'[Volume]), 'Table'[Year].[Year] = 2021) var volume2019 = CALCULATE(sum('Table'[Volume]),'Table'[Year].[Year] = 2019) return (volume2021 - volume2019) / volume2019
@Anonymous wrote:
I am trying to display the percentage growth between the 2019 and 2021 in a Card which will be unaffected even if I select any year for any other visual
You could do that with a measure like the following
Growth = var volume2021 = CALCULATE(sum('Table'[Volume]), Year('Table'[Year]) = 2021) var volumne2019 = CALCULATE(sum('Table'[Volume]), Year('Table'[Year]) = 2019) return (volume2021 - volumne2019) / volumne2019
Thanks for quick reply. I tried your solution. It is not working. It shows 0% always. Then I created another measure for only 2019. It changed every time I select a year. Thats why the first measure is showing 0%.
Sorry, I'm assuming that you are using the auto-datetime hierarchy feature for the slicer. I don't normally use these myself. The following variation should fix this issue.
Growth = var volume2021 = CALCULATE(sum('Table'[Volume]), 'Table'[Year].[Year] = 2021) var volume2019 = CALCULATE(sum('Table'[Volume]),'Table'[Year].[Year] = 2019) return (volume2021 - volume2019) / volume2019
Thanks a lot. That worked well.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
94 | |
80 | |
68 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |