cancel
Showing results for
Did you mean:
New Member

## Calculate only if exist on previous periods

Hi,

I have a business, that owns different shops, and we want to compare data of sales of different periods (should be at different periods level, yearly, monthly, weekly) but we need to be sure that the data I'm comparing exist in both periods.

For instance, if we want to compare the data of this same week last year and shop A was still not open this week, I want it to not be included in the calculations.

My table contains fields as:

TrasactionId, Shop, DateId,Sales

and I was thinking of creating a kind of flag (0/1) to mark if a row show is used in the calculation according to the previous logic, but I'm a bit blocked. I guess doing so and the day level will make it work at any other level.

Does someone suggest me a different approach?

1 ACCEPTED SOLUTION
Super User IV

@JMerino , On is period vs period or range vs range.

else you combine few time intelligence measures and use them with help from measure slicer

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))
Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

Create a slicer and with help of that change current and prior measure (Month, Qtr, Year)

very similar to measure slicer

Proud to be a Super User!

2 REPLIES 2
Super User IV

@JMerino , On is period vs period or range vs range.

else you combine few time intelligence measures and use them with help from measure slicer

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))
Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

Create a slicer and with help of that change current and prior measure (Month, Qtr, Year)

very similar to measure slicer

Proud to be a Super User!

New Member

Hi,

Announcements