0
votes

Very new to Power BI, so any help is appreciated.

I have a database table that has fields Category, SubCategory, Value and ReportDate. The Value is not a sales figure, it's a point-in-time valuation (think stock value). This gets populated every day, so I have rows with contiguous dates and the value changing each day.

I'm looking to make a table report that has Category, Value Today, Value 30 Days Ago and Value 90 Days Ago (these value columns need to be summed by category). Delta columns would be an added bonus. All the data required for something like this is in the table I think but I'm not sure how to approach it.

I have created a Date table (like here http://community.powerbi.com/t5/Desktop/how-to-calculate-month-over-month-sales/m-p/63647/highlight/false#M26258) hoping it would help but I'm not getting anywhere.

I've tried adding these measures to the report:

CurrentDayValue = CALCULATE(SUM(ValuationTable[Value]), DATEADD(DateTable[Date], 0, MONTH))

30DayValue = CALCULATE(SUM(ValuationTable[Value]), DATEADD(DateTable[Date], -30, DAY))

But they are both the same value (and are also the same as just adding my [Value] column). If I don't display my measures and just show my [Value] and add a filter on the ReportDate, I can see all my dates and selecting just 1 date results in a value I expect. I can also then just filter on a previous date and see the correct value for that date, but I want these to be side by side in the report.

1

1 Answers

0
votes

I think I have something that works. Would be interested in hearing feedback if this is a good approach or if there's a better way:

Previous Value = 
CALCULATE (
    SUM (ValuationTable[Value]),
        FILTER (
            ALL (ValuationTable),
            COUNTROWS (
                FILTER (
                    ValuationTable,
                    EARLIER (ValuationTable[ReportDate]) = DATEADD(ValuationTable[ReportDate], -30, DAY)
                        && EARLIER (ValuationTable[Category]) = ValuationTable[Category]
                 )
            )
      )
)