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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
asmagh
Helper I
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

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))

View solution in original post

7 REPLIES 7
Greg_Deckler
Super User
Super User

Something like:

 

 

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

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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) 

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))

simply awesome..saved my day 🙂

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.


Hi,

Try this

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


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@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.
1.PNG

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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