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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
danidan
Regular Visitor

Showing number of orders in the same previous period

I want to show the number of orders made in the same period as a label in the same card.
For example: If 100 orders are made in the selected date range, I want to show how many orders were made -30 days retrospectively.
Sorry, Im a newbie and I couldn't get exactly how to do it. Any help will be appreciated 🙏

 

 

5 REPLIES 5
v-jingzhang
Community Support
Community Support

Hi  @danidan 

 

How do you get the number of orders in the selected period? Do you use Count on some column? Do you use a date slicer or filter to select a period?

 

Assume you select a continuous period with a slicer and you use Count on an Order ID column, you can try below measure to get the number of orders X days prior to the selected date range.

previous number =
VAR _minDate = MIN ( 'Table'[Date] )
VAR _maxDate = MAX ( 'Table'[Date] )
VAR _xDays = 30
RETURN
    COUNTX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] <= _maxDate - _xDays
                && 'Table'[Date] >= _minDate - _xDays
        ),
        'Table'[Order ID]
    )

 

If your table and model is not similar to my assumptions, please share some sample data and expected result to help us understand the requirement better. 

 

Here is an old thread that gets sum of a column in the previous month with the same period. You could refer to its solutions and modify the start date and end date variables per your need. 

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Calculate-the-previous-month-value-with-the-s...

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

 

 

 

mahoneypat
Microsoft Employee
Microsoft Employee

Do you always want 30 days prior to the selected date range, or previous month?

 

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


@mahoneypat I want to get X days prior to the selected date range

Here is a measure that shows one way to do it.

 

Prior 30 Days =
VAR mindate =
MIN( Data[DateCreated] )
RETURN
CALCULATE(
COUNT( Data[BuybackID] ),
FILTER(
ALL( Data[DateCreated] ),
Data[DateCreated] < mindate
&& Data[DateCreated] >= mindate - 30
)
)

 

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


Added as Measure but there is no data inside

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors