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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
dicere
Frequent Visitor

Amount of open orders on each day

I'm trying to create a measure that calculates the number of orders that are open on each day of the month to place in a bar graph on my dashboard. I used the month of January as an example, but I need it to be for every day of the year.

I have the order number, the start date and the end date. Below I left an example of the table I have, the results I need and how the graph would look.

For example, the first order, Q5466805, I need it to count on days 6, 7, 8 and 9.

 

dicere_0-1736441567179.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @dicere 

Based on your information, I create a table:

vyohuamsft_0-1736928468818.png

Create relationship:

vyohuamsft_1-1736928892868.png

 

Then create a new measure, It's like the dax expression described by Sahir_Maharaj 

Open Orders = 
VAR SelectedDate = SELECTEDVALUE('Date'[Date])
RETURN
    CALCULATE(
        COUNTROWS(
            FILTER(
                'Table',
                'Table'[Start Date] <= SelectedDate &&
                'Table'[End Date] >= SelectedDate
            )
        ),
        CROSSFILTER('Date'[Date], 'Table'[Start Date], NONE),
        CROSSFILTER('Date'[Date], 'Table'[End Date], NONE)
    )

 

Put then in column chart, here is my preview:

vyohuamsft_2-1736928944524.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

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
Anonymous
Not applicable

Hi, @dicere 

Based on your information, I create a table:

vyohuamsft_0-1736928468818.png

Create relationship:

vyohuamsft_1-1736928892868.png

 

Then create a new measure, It's like the dax expression described by Sahir_Maharaj 

Open Orders = 
VAR SelectedDate = SELECTEDVALUE('Date'[Date])
RETURN
    CALCULATE(
        COUNTROWS(
            FILTER(
                'Table',
                'Table'[Start Date] <= SelectedDate &&
                'Table'[End Date] >= SelectedDate
            )
        ),
        CROSSFILTER('Date'[Date], 'Table'[Start Date], NONE),
        CROSSFILTER('Date'[Date], 'Table'[End Date], NONE)
    )

 

Put then in column chart, here is my preview:

vyohuamsft_2-1736928944524.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

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

Sahir_Maharaj
Super User
Super User

Hello @dicere,

 

Can you please try this approach:

Open Orders = 
VAR CurrentDate = SELECTEDVALUE('Calendar'[Date])
RETURN
    COUNTROWS(
        FILTER(
            'Orders',
            'Orders'[start_date] <= CurrentDate &&
            'Orders'[final_date] >= CurrentDate
        )
    )

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

I think this measure is on the way for what I need, but it's still not calculating the correct number.
I have an active relationship between the calendar table and the orders table. I saw in another topic that there shouldn't be this active relationship between the tables because a relationship between the calendar and orders tables will force the orders table to be filtered by each calendar date due to row context.
I think this is affecting the measure and not calculating the correct number, but I can't disable this relationship as it will affect other measurements I already have.

In this topic it was mentioned that it would be possible to use CROSSFILTER() to deactivate this relationship, but I have doubts in which part of the measure I should add CROSSFILTER().

Basically in this measure I am using the “date” column from the calendar table, and the “start_date” and “end_date” columns from the orders table, but the active relationship is between the “date” column from the calendar table and the “activate_date” column from the table of orders.

Could you help me?

Hello @dicere,

 

Thanks for your reponse.

 

Can you please try this updated approach:

Open Orders = 
VAR CurrentDate = SELECTEDVALUE('Calendar'[Date])
RETURN
    CALCULATE(
        COUNTROWS(
            FILTER(
                'Orders',
                'Orders'[start_date] <= CurrentDate &&
                'Orders'[end_date] >= CurrentDate
            )
        ),
        CROSSFILTER('Calendar'[Date], 'Orders'[activate_date], NONE)
    )

 


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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