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
alau
Helper I
Helper I

Calculate weekdays lapsed, but with a twist

Hi all... I am a new PBI user and would love some support on an issue I can't resolved (despite reading through similar Q&A posts)...

 

I have daily sales data loaded in my model, and am trying to calculate a simple average daily sales by weekday (* we only sell during Mon-Fri). I already have a "IsWorkingDay" column in my date table, and have attempted to create the following measure:

 

 
 
No of Sales Days Lapsed = CALCULATE(
     SUM('Date Dimension'[IsWorkingDay]),
           DATESBETWEEN('Date Dimension'[FullDate],
                        STARTOFMONTH('Date Dimension'[FullDate]),
                        LASTDATE(Sales[Invoice Date])))

 

This measure gives me an expected return value of "10" (i.e. I have sales loaded for 1 Oct 2019 to 14 Oct 2019, so that consisted of  10 weekdays in that period). But here is my problem..... when I add in a matrix of my sales broken down by customer, I am getting the following:

 

  

CustomerACT Nett Sales# of Sales Days Lapsed# of Weekdays in MthExtrapolated Full Month Sales
Customer #1 $29,0001023 $66,700
Customer #2 $22,0001023 $50,600
Customer #3 $34,000623 $130,333
Customer #4 $11,0001023 $25,300
Customer #5$7,5001023 $17,250
Customer #6 $6,8001023 $15,640
TOTAL $110,300   $305,823

 

The problem with Customer #3 is that unlike all other customers who purchased every weekday so far this month, he only purchased on 6 weekdays. 

 

As I am now trying to extraplate my MTD sales to the full month, it is giving me a false/inflated estimate of my forecasted sales.

 

How do I modify my DAX so that my [No of Sales Days Lapsed] measure simply takes the latest date within my sales table, regardless of any attribute (e.g. customer, product type, store location, etc.),then minus the start of the month selected, and then work out the number of weekdays lapsed? 

 

Many thanks in advance.

 

Anthony 

1 ACCEPTED SOLUTION

No worries @Greg_Deckler . I will re-draft my data and submit again (* in the right format and forum).

 

Thanks.

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

First, Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490.

 

Second, See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


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

Sorry @Greg_Deckler , new to PBI and this forum, so didn't mean to break the rules. I now realised that I posted to the wrong section, but have no idea how to edit (* might delete and re-post if required). 

I did have a look at your link, but I must admit I do not understand how it can resolve my issue. I am pretty green at PBI, so can you please point me down to the right path?

 

As explained in my initial post, I can get it 99% right. The hurdle is when I dissect my sales data (e.g. by customer), and that my lapsed working days measure fail in instances where the customer did not buy every single weekday.

 

Thanks for your reply. Much apprecaited.   

Oh, it's not so much about any rules but more about the fact that without some sample source data, it is incredibly difficult to replicate your issue and troubleshoot. That was the main point of referring you to the "How to" article.


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

No worries @Greg_Deckler . I will re-draft my data and submit again (* in the right format and forum).

 

Thanks.

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.