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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Counting stores where sales within date range

HI,

I have stores that sale items and I need to find last sale per store within selected (calendar) date range. Sale date is related to calendar date. I want to get one row per StoreID with latest sale date that is older then max selected calendar range, and then tto count those rows. I can't solve this, help is appriciated. Thanks 

This is what I have so far.

TEST := 
VAR MaxCalDateSelected=MAX(Calendar[DAte])
RETURN
CALCULATE( COUNTROWS( Sales, FILTER(Sales,Sales[StoreID] && Sales[TotalPaymentsRunningTotal]>0 && MAX(Sales[TotalPaymentsRunningTotal] && MAX(Sales[SaleDate]<=MaxCalDateSelected)
)

 

2 REPLIES 2
Anonymous
Not applicable

I solved this, solution is to create Summary table using SUMMARIZE, like 

SUMMARIZE(tblSales, [StoreID], CALCULATE(MAX(Saledate),Sales[TotalPaymentsRunningTotal]>0))
v-lili6-msft
Community Support
Community Support

hi, @Anonymous

Please share your sample pbix file or some data sample and expected output.Do mask sensitive data before uploading.

 

 

Best Regards,

Lin

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.