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
dbright
Regular Visitor

Same Store Flag

I need to be able to shows months worth of data assuming a store was live at least 12 months before the reported month. THis means there will be a different abount of stores in my numbers each month as stores reach that 12 month requirement and excluded prior to that. Any help would be appreciated. I am able to do based on report date by doing Today()-365, but that doesnt work for a multi month analysis. For example:

 

March 2018 - $40,000 (based on 123 stores that were at least live as of March 1st 2017))

April 2018 - $55,000 (based on 128 stores that were at least live as of April 1st 2017)

 

I then want to look back to 2017 and get those same stores sales for comparison:

 

March 2017 - $35,000 (based on stores that were at least live as of March 1st 2017 and still live March 1st 2018)

 

Maybe I'm asking for too much...thoughts?

1 ACCEPTED SOLUTION
Seward12533
Solution Sage
Solution Sage

There are a lot of ways to do this. One solution that would be fairly easy to implement if you new to DAX/PowerBI would be to add a calcualted column in your fact table that compare the date in the row to the earliest date reported using DATEDIFF function. Unless of course you have a lookup table of Store opening dates.  There are some single formula dax and other solutions counting number of distinct months in the date table etc but see if this helps you out.  

 

You need a Measure to calcluate the earlierst sales date

Earliest Sales Date = First Sales Date = CALCULATE(MIN(FactTable[TransactionDate]),All(DateTable))

 

Then a Calcualted column in your fact table

Number of Months Open COLUMN = DATEDIFF([TransactionDate],[Earliest Sales Date],Month)

You can then write a measure for 

Sales Stores Open over 1YR = CALCULATE([Sales],Filter(FactTable,FactTable[Number of Months Open]>12)

You could then write similar measures for Count of Stores over 1YR etc...

View solution in original post

2 REPLIES 2
Seward12533
Solution Sage
Solution Sage

There are a lot of ways to do this. One solution that would be fairly easy to implement if you new to DAX/PowerBI would be to add a calcualted column in your fact table that compare the date in the row to the earliest date reported using DATEDIFF function. Unless of course you have a lookup table of Store opening dates.  There are some single formula dax and other solutions counting number of distinct months in the date table etc but see if this helps you out.  

 

You need a Measure to calcluate the earlierst sales date

Earliest Sales Date = First Sales Date = CALCULATE(MIN(FactTable[TransactionDate]),All(DateTable))

 

Then a Calcualted column in your fact table

Number of Months Open COLUMN = DATEDIFF([TransactionDate],[Earliest Sales Date],Month)

You can then write a measure for 

Sales Stores Open over 1YR = CALCULATE([Sales],Filter(FactTable,FactTable[Number of Months Open]>12)

You could then write similar measures for Count of Stores over 1YR etc...

I am somewhat new to the BI world and DAX, but this makes sense. I will work through this today. Thank you for the quick response!

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.