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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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.


Go to My LinkedIn Page


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

 

L12 Std Margin1.JPG

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors