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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
tirumalasettiv
Frequent Visitor

Last 12 months Std Margin calculation

Hello ,

I need to create past 12 months standard margin per each entity,

but I am not sure what to write in the filter condition. Could someone guide me?

For example, entity AE0013, 09/01/2021 last 12 months Std Margin should be the standard margin from 10/01/2020 to 09/01/2021

I have tried the below code with DATESINPERIOD, but got the error.

L12 Std Margin.JPG

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

Hi @tirumalasettiv ,

 

According to your description, here is my solution.

I created a sample.

vxiaosunmsft_0-1663581329845.png

Create a DATE table.

 

DATE =
CALENDAR (
    DATE ( 2021, 1, 1 ),
    DATE ( 2022, 12, 1 )
)

 

Create a column.

 

Column =
CALCULATE (
    SUM ( HFM_IC_MAIN[Std Margin%] ),
    DATESINPERIOD (
        'DATE'[Date],
        'HFM_IC_MAIN'[Date],
        -1,
        YEAR
    )
)

 

Final output:

vxiaosunmsft_1-1663581394655.png

 

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ xiaosun

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

4 REPLIES 4
Anonymous
Not applicable

what's your meaning of get last 12 months margin?  sum margin of all the last 12 months ? 

Last12 = CALCULATE(SUM('Table'[Std Margin%]),FILTER('Table',[Date]>EOMONTH(EARLIER([Date]),-12)&&[Date]<=EARLIER([Date])))
v-xiaosun-msft
Community Support
Community Support

Hi @tirumalasettiv ,

 

According to your description, here is my solution.

I created a sample.

vxiaosunmsft_0-1663581329845.png

Create a DATE table.

 

DATE =
CALENDAR (
    DATE ( 2021, 1, 1 ),
    DATE ( 2022, 12, 1 )
)

 

Create a column.

 

Column =
CALCULATE (
    SUM ( HFM_IC_MAIN[Std Margin%] ),
    DATESINPERIOD (
        'DATE'[Date],
        'HFM_IC_MAIN'[Date],
        -1,
        YEAR
    )
)

 

Final output:

vxiaosunmsft_1-1663581394655.png

 

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ xiaosun

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

Jihwan_Kim
Super User
Super User

Hi,

If dim-calendar-table is not there, please try using EOMONTH function with FILTER function.

somthing like,

 

FILTER ( ..... , HFM_IC_MAIN[date] > EOMONTH( TODAY(), -13) )

 

https://dax.guide/eomonth/

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

No luck , geeting last 12 months Std Margin % same as Std Margin.

 

L12 Std Margin1.JPG

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.