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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
DGTL
Helper I
Helper I

DAX Calculate delay per month

 

Hello,

Can you unlock me on a Dax measure?


I would like to have a monthly bar chart with a calculation of overdue orders each month.

Example:
The customer requests a delivery for the 02/01/2021 (DELIVERY REQUESTED DATE)
Delivery is delivered late on 03/15/2021 (DELIVERY DATE)

My histogram should look like this

Capture.PNG

Capture 2.PNG Thank you so much !
7 REPLIES 7
ERD
Super User
Super User

Hello @DGTL ,

One of the options to achieve your result:

1. Create a calendar table with months (first day of each month). This table will be used for your X axis. No relations are needed.

Example:

[Date] (month/day/year)

5/1/2020
6/1/2020
7/1/2020
8/1/2020
9/1/2020
etc

2. Create a measure:

Overdue orders = 
VAR currentDate = EOMONTH(SELECTEDVALUE('Calendar'[Date]), 0)
VAR result = 
CALCULATE(
    COUNTROWS(Overdue_orders),
    FILTER(Overdue_orders,
        currentDate >= Overdue_orders[Requested date]  &&
        currentDate <= EOMONTH(Overdue_orders[Delivered date], 0) &&
        Overdue_orders[Requested date] <> Overdue_orders[Delivered date]
    )
)
Return
IF(ISBLANK(result),0,result)

 

Did I answer your question? Mark my post as a solution!

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Hi ERD, thank you so much for your answer ! But not working... 😥

 

View the attachment .pbix : 

https://www.transfernow.net/dl/20210326haKI2cmE 

Another option upon Table Dates:

overdueOrders2 = 
var currentDate2 = SELECTEDVALUE('Table Dates'[Date])
var RES2 = 
CALCULATE(
    COUNTROWS(Overdue_orders),
    FILTER(
        Overdue_orders,
        currentDate2 >= Overdue_orders[Requested date] &&
        currentDate2 <= Overdue_orders[Delivered date]))

Return
IF(ISBLANK(RES2),0,RES2)

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

VAR currentDate = EOMONTH(SELECTEDVALUE('First Month'[First Month]), 0)

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

DGTL
Helper I
Helper I

up please 🙂

Anonymous
Not applicable

Hi,

 

you can create 2 new columns to solve your problem. First create a column with Overdue, like this:

 

OVERDUE = IF('Table'[DELIVERY DATE].[Date] > 'Table'[DELIVERY REQUESTED DATE].[Date],1,0)

 

and then the month form the table you want to call "late", I used the actual delivery date for mine:

 

MONTH = MONTH('Table'[DELIVERY DATE].[Date])

 

After that you can simply create the histogram with the sum of OVERUDE on Y axis and MONTH on X axis.

Thanks Ascarim, 

 

But not working...  if the delivery date have several months late, I would not see it in this case. It must be represented on each late month. Like in the first picture

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.