Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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 🙂
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
135 | |
117 | |
101 | |
71 | |
61 |