cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
christianyepez2 Regular Visitor
Regular Visitor

Bring Last period

Hello Everyone!

 

I need to bring the last period value (Price) for a especific material, for example I bought a specfic material in the week 9 for 94.25 USD, the week 11 for 94.00, the week 10 I didnt buy the product but i want to compare to the last period i realized a purchase.

I am using this calculated column, but it bring the -7 days value, and I need last period:  

last week price=
CALCULATE (
    MAX ( 'Datos compras'[Price] );
    FILTER (
        'Datos compras';
        EARLIER ( 'Datos compras'[date] )
            DATEADD ( 'Datos compras'[date]; +7DAY )
            && 'Datos compras'[MATERIAL] = EARLIER ( 'Datos compras'[MATERIAL] )
    )
)

 

My data looks like this: 

126.PNG

I would like to see the last value, regarthless of the date

I need some help please!

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
v-cherch-msft Super Contributor
Super Contributor

Re: Bring Last period

Hi @christianyepez2 

You may add an index column with RANKX Function and then get the last period price with index column.For example:

Index =
RANKX (
    FILTER ( 'Table', 'Table'[Material] = EARLIER ( 'Table'[Material] ) ),
    'Table'[Date],
    ,
    ASC
)
Last Period Price =
CALCULATE (
    MAX ( 'Table'[Price] ),
    FILTER (
        'Table',
        'Table'[Material] = EARLIER ( 'Table'[Material] )
            && 'Table'[Index]
                = EARLIER ( 'Table'[Index] ) - 1
    )
)

1.png

Regards,

Community Support Team _ Cherie Chen
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-cherch-msft Super Contributor
Super Contributor

Re: Bring Last period

Hi @christianyepez2 

You may add an index column with RANKX Function and then get the last period price with index column.For example:

Index =
RANKX (
    FILTER ( 'Table', 'Table'[Material] = EARLIER ( 'Table'[Material] ) ),
    'Table'[Date],
    ,
    ASC
)
Last Period Price =
CALCULATE (
    MAX ( 'Table'[Price] ),
    FILTER (
        'Table',
        'Table'[Material] = EARLIER ( 'Table'[Material] )
            && 'Table'[Index]
                = EARLIER ( 'Table'[Index] ) - 1
    )
)

1.png

Regards,

Community Support Team _ Cherie Chen
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

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 532 members 4,327 guests
Please welcome our newest community members: