Forum Discussion
ilcaa72
Helper IV
8 years agoreturn multiple Vars in Dax
im new to Dax. here is my Dax formula. I keep messing up and pressing alt enter, then enter incorrectly which deletes my columns... what is the proper syntax to return all 3 variables at the sa...
- Anonymous8 years ago
Try this. It's a little advanced, and came from www.sqlbi.com Check out this article for the full explanation
Calendar = VAR BaseCalendar = CALENDAR ( DATE ( 2016, 1, 1 ), DATE ( YEAR( TODAY() ), 12, 31 ) ) RETURN GENERATE ( BaseCalendar, VAR BaseDate = [Date] VAR YearDate = YEAR ( BaseDate ) VAR MonthNumber = MONTH ( BaseDate ) VAR MonthName = FORMAT ( BaseDate, "mmmm" ) VAR YearMonthName = FORMAT ( BaseDate, "mmm yy" ) VAR YearMonthNumber = YearDate * 12 + MonthNumber – 1 RETURN ROW ( "Day", BaseDate, "Year", YearDate, "Month Number", MonthNumber, "Month", MonthName, "Year Month Number", YearMonthNumber, "Year Month", YearMonthName ) )
Anonymous
8 years agoNot applicable
Try this. It's a little advanced, and came from www.sqlbi.com Check out this article for the full explanation
Calendar =
VAR BaseCalendar =
CALENDAR ( DATE ( 2016, 1, 1 ), DATE ( YEAR( TODAY() ), 12, 31 ) )
RETURN
GENERATE (
BaseCalendar,
VAR BaseDate = [Date]
VAR YearDate = YEAR ( BaseDate )
VAR MonthNumber = MONTH ( BaseDate )
VAR MonthName = FORMAT ( BaseDate, "mmmm" )
VAR YearMonthName = FORMAT ( BaseDate, "mmm yy" )
VAR YearMonthNumber = YearDate * 12 + MonthNumber – 1
RETURN ROW (
"Day", BaseDate,
"Year", YearDate,
"Month Number", MonthNumber,
"Month", MonthName,
"Year Month Number", YearMonthNumber,
"Year Month", YearMonthName
)
)