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

Previous Date value by country and product and with missing days

Hi Guys,

 

I have following table

Tableview.PNG

 

And I'm looking to retrieve the previous value for the date before (attention, list does not contain all days as the weekend or Holidays are not included) for the same product and for the same country.

 

I tried already a measure with EARLIER but due to the missing days this is not working. 

 

Do you have any idea how I could solve this ?

 

Thanks in advance already,

Jan

1 ACCEPTED SOLUTION
Community Champion
Community Champion

@JanLofgren

 

Try this calculated column

 

Column =
VAR currentdate = TableName[Date]
VAR PreviousDate =
    CALCULATE (
        MAX ( TableName[Date] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[Country], TableName[Product] ),
            TableName[Date] < currentdate
        )
    )
RETURN
    CALCULATE (
        SUM ( TableName[Value] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[Country], TableName[Product] ),
            TableName[Date] = PreviousDate
        )
    )
Regards,
Zubair


View solution in original post

1 REPLY 1
Community Champion
Community Champion

@JanLofgren

 

Try this calculated column

 

Column =
VAR currentdate = TableName[Date]
VAR PreviousDate =
    CALCULATE (
        MAX ( TableName[Date] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[Country], TableName[Product] ),
            TableName[Date] < currentdate
        )
    )
RETURN
    CALCULATE (
        SUM ( TableName[Value] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[Country], TableName[Product] ),
            TableName[Date] = PreviousDate
        )
    )
Regards,
Zubair


View solution in original post

Helpful resources

Announcements
secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

Microsoft Ignite

Microsoft Ignite with Arun Ulag

Featured Session: Drive Data Culture with Power BI- Vision, Strategy & Roadmap. Register here https://myignite.microsoft.com #MSIgnite #PowerPlatform #Power BI ​

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors