Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Stuk
Helper I
Helper I

calendar with today function

Capture.PNG

Hello everyone

it may be stupid but i don't understand how to use Today function, it's the same with the Month function could you help me please?

2 ACCEPTED SOLUTIONS
KHorseman
Community Champion
Community Champion

TODAY() returns a date already. You don't need to nest it in a DATE() function. The formula should be

 

DateTable = CALENDAR(
	DATE(2015; 6; 1);
	TODAY()
)

I recommend naming your calendar table "DateTable" instead of "Calendar". The word Calendar is reserved for the function named CALENDAR(), so every time you refer to that table you would have to put its name in single quotes. I find typing extra quotes around my table names annoying and try to avoid it wherever possible.

 

So you would be able to type

 

Measure = CALCULATE( [MeasureName], DATESYTD(DateTable[Date]))

 

instead of

 

Measure = CALCULATE( [MeasureName], DATESYTD('Calendar'[Date]))

because

 

Measure = CALCULATE( [MeasureName], DATESYTD(Calendar[Date]))

would return an error.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

The purpose of the DATE() function is to construct dates from components. It requires 3 separate arguments: a year, a month, and a day, each in the form of a whole number, and from that it returns a single item as its output: a full date. TODAY() takes no arguments, and also returns a single item: a full date. So TODAY() when nested in another function only constitutes one argument, not three, and also it doesn't fit the requirements of any of the three arguments needed for DATE(). It isn't a year, it isn't a month, and it isn't a day. It's a full date.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

7 REPLIES 7
KHorseman
Community Champion
Community Champion

The error has nothing to do with the TODAY() function. You've made two mistakes: 1) you left out the semicolon between the first and second argument in the CALENDAR() function, and 2) you entered a year as the second argument when you should have entered a date. YEAR(TODAY()) would return "2017" which is not a date.

 

Are you trying to generate a column between June 1, 2015 and today's date? If so, get rid of that YEAR() function and put a semicolon between the first date and the second.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




i'm trying to create a calendar to the first date of my database to the actual day to be able use it as database for filters like "sales from the two last weeks"

KHorseman
Community Champion
Community Champion

TODAY() returns a date already. You don't need to nest it in a DATE() function. The formula should be

 

DateTable = CALENDAR(
	DATE(2015; 6; 1);
	TODAY()
)

I recommend naming your calendar table "DateTable" instead of "Calendar". The word Calendar is reserved for the function named CALENDAR(), so every time you refer to that table you would have to put its name in single quotes. I find typing extra quotes around my table names annoying and try to avoid it wherever possible.

 

So you would be able to type

 

Measure = CALCULATE( [MeasureName], DATESYTD(DateTable[Date]))

 

instead of

 

Measure = CALCULATE( [MeasureName], DATESYTD('Calendar'[Date]))

because

 

Measure = CALCULATE( [MeasureName], DATESYTD(Calendar[Date]))

would return an error.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




thank you very much it's alright now !

Amzad
Frequent Visitor

Hey Stuk, what was work aound to achive  the DAX comand                                                                                                        As i have Dates from 2009 till 2027 and more 

i need DAX command  from  2016 till date like today                                                                                                            Can you help me   Thanks in advance 

The purpose of the DATE() function is to construct dates from components. It requires 3 separate arguments: a year, a month, and a day, each in the form of a whole number, and from that it returns a single item as its output: a full date. TODAY() takes no arguments, and also returns a single item: a full date. So TODAY() when nested in another function only constitutes one argument, not three, and also it doesn't fit the requirements of any of the three arguments needed for DATE(). It isn't a year, it isn't a month, and it isn't a day. It's a full date.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




thanks for the answer but when i'm trying to use date function it tell me that i need at least 3 arguments in this function Capture.PNG

(sorry it's the french version of power bi)

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.