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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
skis
Frequent Visitor

Count of Orders for the last 364 days or until the day before from last year.

Hi,

 

Hope you all had a great thanksgiving. I have a calender table and Orders table. I'm trying to create a measure to give the count of orders for the last 364 days, meaning, need order count from 12/18/2019 to 12/15/2020 and I don't want to consider today. My measure follows, 

 

LateOrders = CALCULATE ( COUNT ('Table'[OrderId]), DATESINPERIOD('DimDate'[Date] , LASTDATE(DimDate[Date]), -364, DAY ))

 

When I use this measure, it's showing me the same count as that of what I got for date range from 12/18/2019 to 12/16/2020. Not sure how to alter the formula not to consider today for the order count. Any ideas ?

 

Thanks in advance.

 

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Please try this expression

 

LateOrders =
VAR vToday =
    TODAY ()
RETURN
    CALCULATE (
        COUNT ( 'Table'[OrderId] ),
        FILTER (
            ALL ( 'DimDate'[Date] ),
            'DimDate'[Date] < vToday
                && 'DimDate'[Date] >= vToday - 365
        )
    )

 

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

1 REPLY 1
mahoneypat
Employee
Employee

Please try this expression

 

LateOrders =
VAR vToday =
    TODAY ()
RETURN
    CALCULATE (
        COUNT ( 'Table'[OrderId] ),
        FILTER (
            ALL ( 'DimDate'[Date] ),
            'DimDate'[Date] < vToday
                && 'DimDate'[Date] >= vToday - 365
        )
    )

 

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors