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
KatkaS
Post Patron
Post Patron

Help with excluding week-end

Hello

 

I have a problem with exlcuding week-ends again... There are lots of suggestions on inyternet and I tried many of them, but still getting error.. I created a separate date table and I would like to calculate difference between Closed date and Approved date..

 

Closed in days = CALCULATE (COUNTROWS ('CALENDAR'),FILTER ('CALENDAR', WEEKDAY ('CALENDAR'[Date], 2 ) < 6 ),DATESBETWEEN ('CALENDAR'[Date],'Report'[Closed Date],'Report'[Approved Date])).
 
Could someone help please?
Thank you.
1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @KatkaS 

According to your description and DAX formula, I guess that you want to get the difference between the count of dates between Approved Date and Closed Date in a period of dates, right?

If so, you can try my steps:

  1. I create a Calendar table that contains all the dates in 2021:
Calendar = CALENDAR(DATE(2021,1,1),DATE(2021,12,31 ))
  1. I create a calculated column within the Calendar table:
Day =

var _weekday=WEEKDAY([Date],2)

return

IF(_weekday>=6,"Closed Date" ,"Approved Date")
  1. I created a measure:
Difference =

var _approved=COUNTX(FILTER(ALL('Calendar'),[Day]="Approved Date"),[Date])

var _closed= COUNTX(FILTER(ALL('Calendar'),[Day]="Closed Date"),[Date])

return

_approved-_closed

Then I create a card chart an place this measure, I can get the correct count, like this:

v-robertq-msft_0-1614839906275.png

 

I guess this can be what you want.

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-robertq-msft
Community Support
Community Support

Hi, @KatkaS 

According to your description and DAX formula, I guess that you want to get the difference between the count of dates between Approved Date and Closed Date in a period of dates, right?

If so, you can try my steps:

  1. I create a Calendar table that contains all the dates in 2021:
Calendar = CALENDAR(DATE(2021,1,1),DATE(2021,12,31 ))
  1. I create a calculated column within the Calendar table:
Day =

var _weekday=WEEKDAY([Date],2)

return

IF(_weekday>=6,"Closed Date" ,"Approved Date")
  1. I created a measure:
Difference =

var _approved=COUNTX(FILTER(ALL('Calendar'),[Day]="Approved Date"),[Date])

var _closed= COUNTX(FILTER(ALL('Calendar'),[Day]="Closed Date"),[Date])

return

_approved-_closed

Then I create a card chart an place this measure, I can get the correct count, like this:

v-robertq-msft_0-1614839906275.png

 

I guess this can be what you want.

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PhilipTreacy
Super User
Super User

Hi @KatkaS 

Upload the PBIX file to OneDrive or Dropbox then post a link to it in here.

regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @KatkaS 

What exactly is the issue?  That DAX looks ok.

Can you please provide your data/PBIX file.

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hello Philip,

it seems the date format was wrong, not the DAX... but now I have an issue with null in the date field..

Can I send the dashboard to you..? How? Thank you very much!

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.