Forum Discussion
Dax formula error
Hi experts
I have the following DAX formula.....which do not work with certain visuals...but work with others. i am trying to work out the previous 12 months based on a selected year and month field from a slicer.... the first formula should dynamically work out the previous 12 months and the second the current period cannot see the error.
Datefilter12Month:=
VAR MonthsToLookBack = 12
VAR DataTableDate = MIN('Date'[Date])
VAR DateTableDate = MIN('DateFilter'[Full Date])
VAR DateAddAlternative = EDATE(DateTableDate,-MonthsToLookBack)
RETURN
IF(
(DataTableDate <= DateTableDate) &&
(DataTableDate > DateAddAlternative) ,
1
)
DatefilterCurrentMonth:=
VAR DataTableDate = MIN('Date'[Date])
VAR DateTableDate = MIN('DateFilter'[Full Date])
RETURN
IF(
(DataTableDate = DateTableDate),
1
) 14 Replies
- TomMartensSuper User
Hey,
it would be helpful if provide the error message as well :-)
Looking at you code I see that both of
return (s)
are not nested, I guess that this is reponsible for the error.
Hopefully this answers your question, if not please consider to create a pbix file with sample data, upload the file to onedrive or dropbox and share the link.
Regards,
Tom
- AnonymousNot applicable
Hi Tom...
Sorry cannot do, ill get killed if i upload a file... and to re create it going to take for every......not sure what you mean by nested,,
- AnonymousNot applicable
Also the there are two measures there just posted into once "insert Code" scereen..
- AnonymousNot applicableHi Tom
Is I upload a file can you delete it after the solution?- TomMartensSuper User
Hey,
I'm sorry I got confused by the two measures in one code screen, sorry for that.
Please consider to create sample data, just an Excel file and a PBIX file. I will not download any file that I have to delete after I find a solution (if I ever will) or that you provide via a direct message.
Regards,
Tom