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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
LamSar
Helper III
Helper III

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.