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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
cottrera
Post Prodigy
Post Prodigy

Dax Count rows todays date and previous day - working days

Hi I have two tables , a dates table (which diplays working and non working days)and a facts table. I require 2 dax measures please

 

Measure 1 Count of facts table rows for today - working days only

Measure 2 Count of facts table rows for previous day- working days only

 

 

Dates Table  
DateIs working dayDay
25/05/20201Mon
26/05/20201Tue
27/05/20201Wed
28/05/20201Thu
29/05/20201Fri
30/05/20200Sat
31/05/20200Sun
01/06/20201Mon
02/06/20201Tue
03/06/20201Wed
04/06/20201Thu
05/06/20201Fri
06/06/20200Sat
07/06/20200Sun
   
   
Facts Table  
DateTrade 
29/05/2020PLUM 
29/05/2020PLUM 
29/05/2020ELEC 
29/05/2020ELEC 
29/05/2020ELEC 
29/05/2020ELEC 
29/05/2020ELEC 
29/05/2020DRAIN 
01/06/2020DRAIN 
01/06/2020DRAIN 
01/06/2020DRAIN 
01/06/2020DRAIN 
01/06/2020DRAIN 
01/06/2020DRAIN 

 

 

thank you

 

RIchard

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@cottrera , not very clear, this how you can get day wise data

Last Day Non Continous = CALCULATE(sum('order'[Qty]),filter(all('Date'),'Date'[Date] =MAXX(FILTER(all('Date'),'Date'[Date]<max('Date'[Date])),Table['Date'])))
or
Day behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Day))
or
Last Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))
////
This Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
Or
This Day =sum('order'[Qty])

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@cottrera , not very clear, this how you can get day wise data

Last Day Non Continous = CALCULATE(sum('order'[Qty]),filter(all('Date'),'Date'[Date] =MAXX(FILTER(all('Date'),'Date'[Date]<max('Date'[Date])),Table['Date'])))
or
Day behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Day))
or
Last Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))
////
This Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
Or
This Day =sum('order'[Qty])

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

thank you I will check out the links you have sent before continuing with this problem therefore marking this post as resolved

aj1973
Community Champion
Community Champion

Hi,

in your date tabe add a column for working days and none working days and use DAX

WorkingDay_Mark =
VAR WeekDayNum =
WEEKDAY ( DimDate[Date] )
RETURN
(
IF ( WeekDayNum = 1 || WeekDayNum = 7 ,0,1)
)
 
 

Working days.PNG

 

then Count rows that contain 1

 

Let me know how it works out for t

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Hi 

 

thank you for your response. I already have this column on my dates table. I am having trouble explaining what I want possibly down to lack of knowledge.

 

aj1973
Community Champion
Community Champion

It's ok,

maybe if you can send us a Dummy Pibx file and your needs we will be more helpfull.

 

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Greg_Deckler
Community Champion
Community Champion

@cottrera - Sorry, I am not clear on what you want. What would be your expected results from the information provided and why?



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi based on the table below and using 2 dax formulas one for each result I would expect these results

Todays result (01/06/2020) = 6
Previous working day (29/05/2020 = 4

 

 

DateTrade
25/05/2020PLUM
25/05/2020DRAIN
25/05/2020DRAIN
25/05/2020DRAIN
25/05/2020DRAIN
25/05/2020DRAIN
25/05/2020DRAIN
26/05/2020ELEC
26/05/2020ELEC
26/05/2020ELEC
27/05/2020ELEC
27/05/2020ELEC
27/05/2020ELEC
28/05/2020PLUM
29/05/2020PLUM
29/05/2020PLUM
29/05/2020PLUM
29/05/2020PLUM
30/05/2020PLUM
30/05/2020PLUM
31/05/2020PLUM
01/06/2020PLUM
01/06/2020ELEC
01/06/2020ELEC
01/06/2020DRAIN
01/06/2020DRAIN
01/06/2020ELEC

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.