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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Velvetine27
Helper I
Helper I

recurring calculation for past 30 days

Hi,

 

Im looking to display a table that looks like this :

MonthM -12M -11M -10M -9M -8M -7M -6M -5M -4M -3M -2M -1M 0 - MTD
INV             
DOH             
COGS             

 

For the M1 calculation will include dates between today-29 to today-59. M2 will be today-59 to today - 89. Is there a simpler way for me to do rather than creating a measure for each of it which will give me around 36 measures ?

 

Any help is appreciated.


Thanks in advance ! 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Velvetine27 

>>  calculation for past 30 days

vxiaotang_0-1670230859011.png

I create an example for your reference, please try this,

Measure = 
var _header= MAX('Dimension'[Dimension])
return 
SWITCH(TRUE(),
_header="M 0 - MTD",SUMX(FILTER('Table','Table'[Date]<=TODAY() && 'Table'[Date]>= EDATE(TODAY(),-1)),[Value]), // -30 day
_header="M -1",     SUMX(FILTER('Table','Table'[Date]< EDATE(TODAY(),-1) && 'Table'[Date]>= EDATE(TODAY(),-2)),[Value]),
_header="M -2",      SUMX(FILTER('Table','Table'[Date]< EDATE(TODAY(),-2) && 'Table'[Date]>= EDATE(TODAY(),-3)),[Value])
)

 

vxiaotang_1-1670234204821.png

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @Velvetine27 

>>  calculation for past 30 days

vxiaotang_0-1670230859011.png

I create an example for your reference, please try this,

Measure = 
var _header= MAX('Dimension'[Dimension])
return 
SWITCH(TRUE(),
_header="M 0 - MTD",SUMX(FILTER('Table','Table'[Date]<=TODAY() && 'Table'[Date]>= EDATE(TODAY(),-1)),[Value]), // -30 day
_header="M -1",     SUMX(FILTER('Table','Table'[Date]< EDATE(TODAY(),-1) && 'Table'[Date]>= EDATE(TODAY(),-2)),[Value]),
_header="M -2",      SUMX(FILTER('Table','Table'[Date]< EDATE(TODAY(),-2) && 'Table'[Date]>= EDATE(TODAY(),-3)),[Value])
)

 

vxiaotang_1-1670234204821.png

 

Best Regards,

Community Support Team _Tang

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

FreemanZ
Super User
Super User

can you provide more detail about your expected result and paste it as a picture? 

hey thanks for your reply. Im looking for something like this. Not sure if this clarifies much, but basically im looking to get this range until M-12.

Velvetine27_0-1669126076374.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.