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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
pani_victoria
Helper I
Helper I

revenue by store opening date

Hi, all!


I have a table of sales by day and store (@sales), I have a table of stores with opening and closing dates (@stores). These tables are related.
The report has a filter with period selection.

I would like to calculate revenue only for those stores whose opening date is less than the minimum period in the filter - 1 year.


For example:
The period selected in the filter is Jan 23-Dec 23, which means revenue for stores with an opening date less than Jan 22 should be calculated.


I started by creating a measure that calculates the date min period -1 year

selection_date = CALCULATE(min('Date'[Date]), DATEADD('Date'[Date], -1, YEAR))


Then I try to calculate the revenue

 

CALCULATE('#measures'[revenue],
SUMMARIZE('@sales', '@stores'[store]),
CALCULATETABLE(
SUMMARIZE('@sales', '@stores'[store]),
'@stores'[opening_date]<'#measures'[selection_date]))


But my measure doesn't work, I need help

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@pani_victoria ,

Measure =

var _min1 = Minx(allselected(Date), Date[Date])

Var _min = date(year(_min1), Month(_min1), day(_min1))

return

CALCULATE('#measures'[revenue],filter('stores', 'stores'[opening_date]<_min ))

 

If date of date table  is joined to some other column

 

Measure =

var _min1 = Minx(allselected(Date), Date[Date])

Var _min = date(year(_min1), Month(_min1), day(_min1))

return

CALCULATE('#measures'[revenue],filter('stores', 'stores'[opening_date]<_min ), all('Date') )

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

Does this measure work?

Measure = CALCULATE([revenue],filter(values(@stores[store]),'@stores'[opening_date]<[selection_date]))

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

View solution in original post

4 REPLIES 4
pani_victoria
Helper I
Helper I

Thank you! You are monsters!💪👍

v-shex-msft
Community Support
Community Support

Hi @pani_victoria ,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

Does this measure work?

Measure = CALCULATE([revenue],filter(values(@stores[store]),'@stores'[opening_date]<[selection_date]))

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

@pani_victoria ,

Measure =

var _min1 = Minx(allselected(Date), Date[Date])

Var _min = date(year(_min1), Month(_min1), day(_min1))

return

CALCULATE('#measures'[revenue],filter('stores', 'stores'[opening_date]<_min ))

 

If date of date table  is joined to some other column

 

Measure =

var _min1 = Minx(allselected(Date), Date[Date])

Var _min = date(year(_min1), Month(_min1), day(_min1))

return

CALCULATE('#measures'[revenue],filter('stores', 'stores'[opening_date]<_min ), all('Date') )

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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