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.
Good MorningEverybody,
I am hoping that you can assist with a calculation error I am having. I am attempting to create a new column which will show
Hi @apowerbiguy ,
Try the following syntax:
PY Availability =
CALCULATE (
SELECTEDVALUE ( 'Availability'[Availability] ),
FILTER (
ALL ( 'Availability' ),
'Availability'[Year]
= EARLIER ( 'Availability'[Year] ) - 1
&& 'Availability'[Quarter] = EARLIER ( 'Availability'[Quarter] )
&& 'Availability'[BU] = EARLIER ( 'Availability'[BU] )
)
)
Has you can see the result brings previous year values:
I used the quarter column because it appears that you don't have a monthly value but a quartely value.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHello MFelix,
Thank you so much for replying; however, this will not work because it needs to be the previous year for the same "BU" value and same "Fleet" value. There is a Date Field named "Date" (month was just that we track them monthly) and would need to be the previous year date which is listed as 10/1/2020, 10/1/2021.
For instance:
BU | Fleet | Avail | Date |
A | X | xvalue | 10/1/2020 |
A | Y | 10/1/2020 | |
A | X | 10/1/2021 | |
A | Y | 10/1/2021 | |
B | X | ||
B | Y | ||
B | X | ||
B | Y |
Thank you again for replying
Hi @apowerbiguy ,
As far as I know, DATEADD function will return a table and EARLIER function only support a column. So there should be something wrong in MFelix's code.
Try this code:
Availability Same day in Previous Year =
CALCULATE (
MAX ( 'TableName'[Availability] ),/* IF [Availability] is in number format, try SUM function.*/
FILTER (
ALLEXCEPT ( TableName, TableName[BU], TableName[Fleet] ),
'TableName'[Date]
= DATE ( YEAR ( EARLIER ( TableName[Date] ) ) - 1, MONTH ( EARLIER ( TableName[Date] ) ), DAY ( EARLIER ( TableName[Date] ) ) )
)
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @apowerbiguy ,
You are correct about the Fleet I forgot about it on my calculation regardung the date try the following measure:
PY Availability =
CALCULATE (
SELECTEDVALUE ( 'Availability'[Availability] ),
FILTER (
ALL ( 'Availability' ),
'Availability'[Year]
= EARLIER ( 'Availability'[Year] ) - 1
&& 'Availability'[Date] = EARLIER ( DATEADD('Availability'[Date] ), -1 , YEAR))
&& 'Availability'[BU] = EARLIER ( 'Availability'[BU] )
&& 'Availability'[Fleet] = EARLIER ( 'Availability'[Fleet] )
)
)
Did this by heart if it gives an error should be on the DATEADD, please tell me.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi,
Sorry but the year column can't be used. The only columns that would be there is what is the table seen in the reply Fleet, BU, Avail, and Date.
My apologies
Hi @apowerbiguy ,
You can remove the Year from the sintax.
PY Availability =
CALCULATE (
SELECTEDVALUE ( 'Availability'[Availability] ),
FILTER (
ALL ( 'Availability' ),
'Availability'[Date] = EARLIER ( DATEADD('Availability'[Date] ), -1 , YEAR))
&& 'Availability'[BU] = EARLIER ( 'Availability'[BU] )
&& 'Availability'[Fleet] = EARLIER ( 'Availability'[Fleet] )
)
)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsCovering 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 |
---|---|
107 | |
100 | |
80 | |
63 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |