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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Calculating previous week numbers based on slicer values.

I am attempting to calculate previous week numbers for order count based on a slicer value input.

I am using a date table and have created a relationship between it and my data table based off a date value in the data table. The slicer selection is using the date table to pass the current selected value to my measure. What I have attempted is below. 

 

LW Total Order Count =
var PREVWEEK=SELECTEDVALUE('Ship Calendar'[WeekNum])
RETURN
CALCULATE(DISTINCTCOUNT('Data'[Order_Id]),'Data'[Reason_Code]="",'Data'[Order_Id]<>"",'Data'[Most Recent] ="yes",FILTER(ALL('Data'),'Data'[Ship Week]=PREVWEEK))

 

 

 

The issue appears to be when using the ALL() with the other filters withing calculate. It returns a distinct count of all orders for the previous week without applying any filters.Is there a way to maintain previous filters within calculate while also not applying the Ship week filter from the slicer to the calcuation so I don't receive (BLANK) due to both the slicer value and the measure filter being applied simultaneous?


Any help would be greatly appreciated!

 

 

 

EDIT: I was able to solve this utilizing the following measure changes. 

LW Total Order Count =
var PREVWEEK=SELECTEDVALUE('Ship Calendar'[WeekNum])-1
var CurrYear=SELECTEDVALUE('Ship Calendar'[Year])
RETURN
CALCULATE(DISTINCTCOUNT('Data'[Order_Id]),'Data'[Reason_Code]="",'Data'[Order_Id]<>"",'Data'[Most Recent] ="yes",FILTER(ALL('Ship Calendar'),'Ship Calendar'[Ship Week]=PREVWEEK),FILTER(ALL('Ship Calendar'),'Ship Calendar'[Year] = CurrYear))

 

 

 

1 REPLY 1
Ashish_Mathur
Super User
Super User

Hi,

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.