Forum Discussion
MAXDate and Maxdate)lastyear with value
- Anonymous2 years ago
Hi RasmusN532 ,
Thanks for the reply from lbendlin .
Please try modifying your measure syntax as follows:
IRevenue MAX (Last Year) = VAR_a = MAX(calendar[invoice_date]) VAR SameDayLastYear = DATE ( YEAR ( _a ) - 1, MONTH ( _a ), DAY ( _a ) ) VAR_b = CALCULATE ( MAX ( calendar[invoice_date] ), calendar[invoice_date] <= SameDayLastYear, NOT (ISBLANK ([Revenue] ) ) ) RETURN CALCULATE ( [Revenue], FILTER ( calendar, calendar[invoice_date] = _b ) )The logic of this measure is:
Start by determining the current date of the current year.
Count the same day last year.
Finds the same or previous date in the last year that had revenue that was not null.
Calculate the revenue for the corresponding date based on the found date.
If this modified syntax does not help you solve the problem, please provide me with the pbix file. Remember not to log in to the current account when uploading files to Power Bi Desktop.
Best Regards,
Yang
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Hi RasmusN532 ,
Thanks for the reply from lbendlin .
Please try modifying your measure syntax as follows:
IRevenue MAX (Last Year) =
VAR_a =
MAX(calendar[invoice_date])
VAR SameDayLastYear =
DATE ( YEAR ( _a ) - 1, MONTH ( _a ), DAY ( _a ) )
VAR_b =
CALCULATE (
MAX ( calendar[invoice_date] ),
calendar[invoice_date] <= SameDayLastYear,
NOT (ISBLANK ([Revenue] ) )
)
RETURN
CALCULATE ( [Revenue], FILTER ( calendar, calendar[invoice_date] = _b ) )
The logic of this measure is:
Start by determining the current date of the current year.
Count the same day last year.
Finds the same or previous date in the last year that had revenue that was not null.
Calculate the revenue for the corresponding date based on the found date.
If this modified syntax does not help you solve the problem, please provide me with the pbix file. Remember not to log in to the current account when uploading files to Power Bi Desktop.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!