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.
Hi everybody,
I currently have a table where I want to see the YoY growth rate for different locations. The date I have been using is not continuous or has an specific pattern, so when I tried doing YoY calculation I always received the following error: "Function DATEADD expects a contiguous selection when the date column is not unique, has gaps...". Is there perhaps a way to calculate YoY rate for no continous dates??
The table I'm working with looks like this, where Nod is a location and the amount per year describes the sales:
What I would like to have is the percent difference table calculation that you can find in Tableau:
The measures I used were:
YOY diff =
VAR previousDateWithPrice =
CALCULATE (
MAX ( 'capa'[Dates]),
FILTER ( ALL ( 'capa' ), 'capa'[Sales] > 0 && 'capa'[Dates] < MAX ( 'capa'[Dates] ) )
)
VAR previousPrice =
CALCULATE (
SUM ('capa'[Dates] ),
FILTER ( ALL ( 'capa' ), 'capa'[Dates] = previousDateWithPrice )
)
RETURN
DIVIDE ( SUM ( 'capa'[Sales] ) - previousPrice, previousPrice )
Thank you in advance!!
Solved! Go to Solution.
Hi @mclaur_and_22 ,
According to your description, if you just want to show the annual growth rate, here's my solution.
This is my sample data.
I modify your formula like this:
YOY diff =
VAR previousDateWithPrice =
CALCULATE (
MAX ( 'capa'[Dates].[Year] ),
FILTER (
ALL ( 'capa' ),
'capa'[Sales] > 0
&& 'capa'[Dates].[Year] < MAX ( 'capa'[Dates].[Year] )
)
)
VAR previousPrice =
CALCULATE (
SUM ( 'capa'[Sales] ),
FILTER (
ALL ( 'capa' ),
'capa'[Nod] = MAX ( 'capa'[Nod] )
&& 'capa'[Dates].[Year] = previousDateWithPrice
)
)
RETURN
DIVIDE ( SUM ( 'capa'[Sales] ) - previousPrice, previousPrice )
Get the correct result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @mclaur_and_22 ,
According to your description, if you just want to show the annual growth rate, here's my solution.
This is my sample data.
I modify your formula like this:
YOY diff =
VAR previousDateWithPrice =
CALCULATE (
MAX ( 'capa'[Dates].[Year] ),
FILTER (
ALL ( 'capa' ),
'capa'[Sales] > 0
&& 'capa'[Dates].[Year] < MAX ( 'capa'[Dates].[Year] )
)
)
VAR previousPrice =
CALCULATE (
SUM ( 'capa'[Sales] ),
FILTER (
ALL ( 'capa' ),
'capa'[Nod] = MAX ( 'capa'[Nod] )
&& 'capa'[Dates].[Year] = previousDateWithPrice
)
)
RETURN
DIVIDE ( SUM ( 'capa'[Sales] ) - previousPrice, previousPrice )
Get the correct result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 |
---|---|
110 | |
95 | |
76 | |
65 | |
51 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |