cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LamSar
Helper II
Helper II

Time intelligence on non-standard calendar table

Good afternoon,

 

I have a requirement. 

I need to calculate sales per stockperiod and per stockperiod-1 (i.e. previous stockperiod).

 

I have the below table:

LamSar_0-1663594499913.png

This table holds the stockperiod, de min and max date per period and the revenue.

Now I need to create a measure that calculates the revenue for the previous stock period. 

i.e. on the row of StockPeriod 2021/01, I need to calculate the revenue for stockPeriode 2020/12. I can't use the standard time intelligence functions for this. 

Any ideas? 

 

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @LamSar ,

I created some data:

vyangliumsft_0-1663639278771.png

Here are the steps you can follow:

1. Create calculated column.

Year =
YEAR('Table'[Date])
Month = MONTH('Table'[Date])

2. Create measure.

Measure =
var _mindate=
DATE(
    MAX('Table'[Year]),MAX('Table'[Month])-1,1)
var _maxdate=
EOMONTH(
    _mindate,0)
return
SUMX(FILTER(ALL('Table'),'Table'[Date]>=_mindate&&'Table'[Date]<=_maxdate),[Period])
Flag =
IF(
    MAX('Table'[Date])=
MINX(FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])&&'Table'[Month]=MAX('Table'[Month])),[Date]),
1,0)

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1663639278773.png

4. Result:

vyangliumsft_2-1663639278780.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
v-yangliu-msft
Community Support
Community Support

Hi  @LamSar ,

I created some data:

vyangliumsft_0-1663639278771.png

Here are the steps you can follow:

1. Create calculated column.

Year =
YEAR('Table'[Date])
Month = MONTH('Table'[Date])

2. Create measure.

Measure =
var _mindate=
DATE(
    MAX('Table'[Year]),MAX('Table'[Month])-1,1)
var _maxdate=
EOMONTH(
    _mindate,0)
return
SUMX(FILTER(ALL('Table'),'Table'[Date]>=_mindate&&'Table'[Date]<=_maxdate),[Period])
Flag =
IF(
    MAX('Table'[Date])=
MINX(FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])&&'Table'[Month]=MAX('Table'[Month])),[Date]),
1,0)

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1663639278773.png

4. Result:

vyangliumsft_2-1663639278780.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

Top Solution Authors