cancel
Showing results for
Did you mean:
Helper I

## calculate number of day of a YTD

Hello , please i need some help is there any way to calculate the number of days of an YTD ??
Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Solution Sage

## Re: calculate number of day of a YTD

Hello,

there are two ways I can tell you by now.

Adapting @Greg_Deckler you can make the year dynamic.

`Measure = DATEDIFF(DATE(YEAR(TODAY(),1,1),TODAY(),DAY)`

If you have a DateTable, which is many cases highly recommended you could use

`Measure = COUNTROWS(DATESYTD(DateTable))`
6 REPLIES 6
Super User IV

## Re: calculate number of day of a YTD

Something like:

`Measure = DATEDIFF(DATE(2018,1,1),TODAY(),DAY)`

---------------------------------------

Not the Power BI thought police...

##### I have NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!

Proud to be a Datanaut!

Helper I

## Re: calculate number of day of a YTD

thank you for your response , but is there another way to make it dinamically , means that it take the date automatically exemple if we were in 201 , i habe to change (2018,1,1) b myself to (2019,1,1) and i want it to be dynamic ( not static)

Moderator

## Re: calculate number of day of a YTD

@asmagh,

Create new a new table using DAX below.

`Date = CALENDAR("2018/1/1","2019/12/31")`

Create measure using DAX below.

`Measure = IF(MAX('Date'[Date])<=TODAY(),DATEDIFF(MAX('Date'[Date]),TODAY(),DAY),DATEDIFF(TODAY(),MAX('Date'[Date]),DAY))`

Use slicer to filter your measure.

Regards,

Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Solution Sage

## Re: calculate number of day of a YTD

Hello,

there are two ways I can tell you by now.

Adapting @Greg_Deckler you can make the year dynamic.

`Measure = DATEDIFF(DATE(YEAR(TODAY(),1,1),TODAY(),DAY)`

If you have a DateTable, which is many cases highly recommended you could use

`Measure = COUNTROWS(DATESYTD(DateTable))`
Helper IV

## Re: calculate number of day of a YTD

Hi .. wondering if you can advise .. I keep getting an error when using this function:

`Measure = DATEDIFF(DATE(YEAR(TODAY(),1,1),TODAY(),DAY)`

Too many arguments were passed to the YEAR function. The maximum argument count for the function is one.

Super User IV

## Re: calculate number of day of a YTD

Hi,

Try this

Measure = DATEDIFF(DATE(YEAR(TODAY()),1,1),TODAY(),DAY)

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

#### ‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

#### Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Top Solution Authors
Top Kudoed Authors