cancel
Showing results for
Did you mean:
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]; +7; DAY )            && 'Datos compras'[MATERIAL] = EARLIER ( 'Datos compras'[MATERIAL] )    ))`

My data looks like this:

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

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Super Contributor

## Re: Bring Last period

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
)
)
```

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.
Super Contributor

## Re: Bring Last period

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
)
)
```

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.

Announcements

#### Challenge: Can You Solve These?

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

#### Community News & Announcements

Get your latest community news and announcements.

#### 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.

#### Win Power BI Swag with Community Kudopalooza!

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

Top Kudoed Authors
Users Online
Currently online: 532 members 4,327 guests
Recent signins: