Forum Discussion
Difference Measure between filtered column values in a matrix
Hi,
There could be a suggestion for this elsewhere, but I've been searching for a while and not found anything! I pull an export from a system every week, the spreadsheet is named the date of the export and it's saved in a folder. Power BI uses that folder as the data source and the source name is converted into a date within the query.
Each row in the export has a unique ID and a value alongside it. I have created a matrix which looks similar to the below:
Export Date 31st July 2019 31st August 2019 30th September 2019 31st October 2019
Unique ID m MB Usage MB Usage MB Usage MB Usage
123456 205 303 210 300
112233 201 200 210 211
232123 101 100 500 400
534234 650 300 250 241
I'm wanting to create a measure that will fit in between each column and work out the difference between one date's value and the other.
There is actually more data than these included dates because a sheet is exported every week, but I have the visual only look at the last date of each month.
Many thanks in advance.
5 Replies
- Greg_DecklerCommunity Champion
So, I would expect that would be something along the lines of:
Measure 1 = CALCULATE([Measure],PREVIOUSMONTH('Dates'[Date]))Or you could brute force it similar to:
Measure 1 = VAR __Date = MAX('Table'[Date]) VAR __Year = YEAR(__Date) VAR __Month = MONTH(__Date) VAR __Day = DAY(__Date) VAR __PreviousDate = IF(__Month = 1,DATE(__Year - 1,12,__Day),DATE(__Year,__Month-1,__DAy)) RETURN CALCULATE([Measure],'Table'[Date] = __PreviousDate)- EuanKonnektisFrequent Visitor
Hi Greg,
Thanks for your quick response. Have I understood you correctly by using this measure for the first example:
Measure = CALCULATE('Data Usage'[Total Usage],PREVIOUSMONTH('Data Usage'[Export Date].[Date]))That one didn't display any values in the matrix:- v-easonf-msftCommunity Support
Hi , EuanKonnektis
There's nothing wrong with Greg_Deckler solution.
I suspect you didn't use the correct calendar table.
"Previousmonth" is a time intelligence function that needs to be used with the calendar table of consecutive date columns.Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.