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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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