March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Solved! Go to Solution.
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!
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!
365 is wrong. Same day last year is 364.
Well I had 365 more of an example, and isnt it 366 since its leap year? Anyway thats not the issue here, I need it to look for the "highest date" last year not after this years maxdate, that has a value
Kind regards,
"Same day" is always 364 (52*7) regardless of leap year.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information or anything not related to the issue or question.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
22 | |
19 | |
16 | |
9 | |
5 |
User | Count |
---|---|
37 | |
29 | |
16 | |
14 | |
12 |