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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors