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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Paco
Frequent Visitor

DAX Function

Hello, I´m trying to get the days from the first day of the month until TODAY (function). In Excel I use WORKDAY.INTL but I don´t know which DAX Function to use or if it´s posible.  

 

 

What I´m trying to get is my daily sales. Example= 100,000/8 . I want to ge the 8 automatically, in this example there are 8 days between apr-1-2016  and apr-9-2016 because I´m not considering Sundays.

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

If you want to automate this - you'll have to incorporate this in your Calendar Table - read about it here

 

http://sqlblog.com/blogs/alberto_ferrari/archive/2011/01/19/working-days-computation-in-powerpivot.a...

View solution in original post

7 REPLIES 7
Sean
Community Champion
Community Champion

@Paco Try this... Let me know if it works

 

Number of Days = DATEDIFF ( STARTOFMONTH(Table1[Date]), ENDOFMONTH(Table1[Date]), DAY)

 

Paco
Frequent Visitor

I really appreciate you quickly answer, I try the function and it's working, theres is only one missing, It's counting Sundays and I don't want to count them. 

 

In Excel the formula WORKDAY.INTL(start_date, days, [weekend], [holidays]) I have to enter 11 inside [holidays] to not to count sundays. 

 

If I use the function Number of Days = DATEDIFF(DATEVALUE("04/01/2016"),TODAY(),DAY)+1  the result is 21 and I need 18 because there are 3 sundays that I don't want to count, 

 

Thank you!! 😄 

 

Note: An apology if there is some misspelling but I´m from Mexico 😄 :S 

Paco
Frequent Visitor

Sean
Community Champion
Community Champion

If you want to automate this - you'll have to incorporate this in your Calendar Table - read about it here

 

http://sqlblog.com/blogs/alberto_ferrari/archive/2011/01/19/working-days-computation-in-powerpivot.a...

Paco
Frequent Visitor

Thank you very much, I already create a table with the days. I´m new in DAX, which funtcion do I have to use to select the column in which I have the value. 

 

I already have my fomula like this:

 

DailySales = TOTALMTD(SUM(Sales2016[Total]),Sales2016[Date])/ (I want to know the function to select the column [Labdays] of the current month from the Days table )

 

I create a table Days with 2 columns 

 

Column 1 [Month] contains the month 1,2,3,4, etc

Column 2 [Labdays] contains laboralbes days example month 1 labdays 25, month 2 labdays 24, etc. 

 

 

 

 

Sean
Community Champion
Community Champion

@Paco I think TotalMTD requires the second part of the formula to point to the calendar/date table

 

so if your formula is not working => change Sales2016[Date] to CalendarTableName[Date Column]

Paco
Frequent Visitor

Thank you very much for your support I already solved it with your help 😄 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.