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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Jake_vc
Frequent Visitor

Prior period sales DAX error

Greetings Power Bi-ians, (is that a thing?)

 

It's been 2 months and since I'm fairly new to Power BI, I would really appreciate your help in solving my doubt/error which has been making me go in circles.

 

I work in the F&B industry, so comparison of sales, transactions, storewise, current and prior is one the many aspects we look at.

 

- We currently have 2 years of data with which we created a dashboard (Jan 2018-Dec 2020).

- Current year and prior year sales are placed as two boxes in a slide.

- In default selection, "Previous" shows the correct value.Capture.JPG

- When we select 1 year period, say Jan-Dec 18/19/20, it shows prior year sales correctly.

 

- The issue arises when we select more than a year. If we select Oct 19 - Dec 20, "Previous" shows Jan 18-Dec 19 figure.Capture-1.JPG

 

- On selecting 2 years (Jan 19-Dec 20), it shows Jan 18- Dec 19 figure.

Capture-2.JPG

 

Below is the DAX measure I've used:

 

Sales per store PY =
IF(
ISFILTERED('Report'[Date])
,CALCULATE([Sales per store], PARALLELPERIOD('Report'[Date], -1, YEAR))
)
 
What we ideally would want to see is just one year selection and data to appear in the dashboard i.e. the selection made of Oct 19-Dec 20 should not be possible. If the user selects Apr-20 as start date, end date should automatically become Mar-21 and likewise on end date selection (Mar-20 would give Apr-19)
 
I have 2 queries:-
1 - Is there anyway that I could limit the selection of dates to just one year?
2 - If I were to go with current DAX and not change date selection, what are the changes required?
 
I would much appreciate your help.
 
Stay safe!!
1 REPLY 1
lbendlin
Super User
Super User

1. if you don't want the users to specify a date range then only give them a slicer with one date (change the slicer type)

2. no other changes required. Unless you want to dive into the intricacies of Year Over Year To Date.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.