This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hello everyone.
Im having a weird problem with something.
Im trying to filter my report for sales up until the last invoice this month compared to same period last month.
Below is my formula:
Solved! Go to Solution.
Hi @Roberto456 ,
This error message may be caused by the value of the day part of the obtained end date being too large. For example, assume that LATESTMONTH you obtained is 2020/3/31, then STARTDATE is 2020/2/1 and ENDDATE is equal to 2020/2/31 based on your original formula. However, February 2020 can only have 28 days at most, but what you get is 31, which does not conform to the date format. Thus an error was reported. Please update the formula of measure Test 2 as below:
Test 2 = VAR LATESTMONTH = CALCULATE(MAX('(Dim) Calendar'[Rolling Month #]),ALL('(Dim) Calendar')) VAR STARTDATE = DATE(YEAR([Latest Invoice]),MONTH([Latest Invoice])-1,1) VAR ENDDATE = EOMONTH(STARTDATE ,0) RETURN IF(MAX('(Dim) Calendar'[Rolling Month #]) = LATESTMONTH, CALCULATE([Metric],FILTER(ALL('(Dim) Calendar'),'(Dim) Calendar'[Date] >= STARTDATE && '(Dim) Calendar'[Date] <= ENDDATE)), CALCULATE([Metric],FILTER(ALL('(Dim) Calendar'),'(Dim) Calendar'[Rolling Month #] = MAX('(Dim) Calendar'[Rolling Month #])-1))) |
Best Regards
Rena
so i figured out the root cause of the problem and its,
VAR ENDDATE = DATE(YEAR([Latest Invoice]),MONTH([Latest Invoice])-1,DAY([Latest Invoice]))
if i put and integer in there it will work,
why would DAY() be causing this issue?
EDIT:
if i replaced DAY([Latest Invoice]) from the fact table to MAX invoice DAte from the Dimension table, it works, but it wont work with filters now...
Hi @Roberto456 ,
This error message may be caused by the value of the day part of the obtained end date being too large. For example, assume that LATESTMONTH you obtained is 2020/3/31, then STARTDATE is 2020/2/1 and ENDDATE is equal to 2020/2/31 based on your original formula. However, February 2020 can only have 28 days at most, but what you get is 31, which does not conform to the date format. Thus an error was reported. Please update the formula of measure Test 2 as below:
Test 2 = VAR LATESTMONTH = CALCULATE(MAX('(Dim) Calendar'[Rolling Month #]),ALL('(Dim) Calendar')) VAR STARTDATE = DATE(YEAR([Latest Invoice]),MONTH([Latest Invoice])-1,1) VAR ENDDATE = EOMONTH(STARTDATE ,0) RETURN IF(MAX('(Dim) Calendar'[Rolling Month #]) = LATESTMONTH, CALCULATE([Metric],FILTER(ALL('(Dim) Calendar'),'(Dim) Calendar'[Date] >= STARTDATE && '(Dim) Calendar'[Date] <= ENDDATE)), CALCULATE([Metric],FILTER(ALL('(Dim) Calendar'),'(Dim) Calendar'[Rolling Month #] = MAX('(Dim) Calendar'[Rolling Month #])-1))) |
Best Regards
Rena
woo it works 🙂
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 28 | |
| 23 | |
| 22 | |
| 16 | |
| 16 |
| User | Count |
|---|---|
| 61 | |
| 35 | |
| 28 | |
| 22 | |
| 22 |