The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I have a measure that calculates the last date in a table:
Last Date in Receipts CY =
MAX(Receipts[BI Date])
I have a second measure that takes that same date and subtracts a year:
Last Date in Receipts PY =
EDATE(MAX(Receipts[BI Date]),-12)
When I drop them onto a card, they both show the date I expect.
I have a table that is created using the first measure that works perfect:
CY =
FILTER (
Receipts,
AND (
Receipts[BI Date] >= DATE ( 2023, 7, 1 ),
Receipts[BI Date] <= [Last Date in Receipts CY]
)
)
Here is where the problem is. When I try to create a second table with everything the same as the CY table, except for that last date is the using the Last Date in Receipts PY Measure, the table does not show any data:
PY =
FILTER (
Receipts,
AND (
Receipts[BI Date] >= DATE ( 2022, 7, 1 ),
Receipts[BI Date] <= [Last Date in Receipts PY]
)
)
If I change my above measure to type in the date manually, it does populate correctly:
PY =
FILTER (
Receipts,
AND (
Receipts[BI Date] >= DATE ( 2022, 7, 1 ),
Receipts[BI Date] <= DATE(2023,03,01)
)
)
What am I doing to that [Last Date in Receipts PY] measure where it is not working to populate the table?
Edited to add: No errors pop up. The column headings do populate but no data populates.
Solved! Go to Solution.
I tried this as well hoping that it would work but not luck so I think it's that I am using edate but I don't know what to use instead:
PY =
FILTER (
Receipts,
AND (
Receipts[BI Date] >= DATE ( 2022, 7, 1 ),
Receipts[BI Date] <= edate([Last Date in Receipts CY],-12)
)
)
Whoever comes to see this in the future, here is what I did that worked:
PY =
VAR PYDateEnd =
EDATE(MAX(Receipts[BI Date]),-12)
VAR PYStartDate =
EDATE(min(CY[BI Date]),-12)
RETURN
FILTER (
Receipts,
AND (
Receipts[BI Date] >= PYStartDate,
Receipts[BI Date] <= PYDateEnd
)
)
The PYStartDate is referencing to take the minimum date in my CY table and subtract out 12. The table wouldn't work when I referenced a measure with EDATE but it worked when I used it as VAR.
Glad to hear you solved the problem! Could you please mark your solution as an ANSWER? This will help more users who are facing the same or similar difficulties. Thank you!
Best Regards,
Yulia Xu
Thanks for letting me know! I'm still very new to PowerBI and the Community.
I tried this as well hoping that it would work but not luck so I think it's that I am using edate but I don't know what to use instead:
PY =
FILTER (
Receipts,
AND (
Receipts[BI Date] >= DATE ( 2022, 7, 1 ),
Receipts[BI Date] <= edate([Last Date in Receipts CY],-12)
)
)