Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Daryn-TP
Regular Visitor

How to make a calculated column that calculates the difference between report dates

So I have data similar to the following example. I need to create a matrix like the second table example. My issue is I can't get a calculated column that calculates the % change between report dates. The report dates are always a week apart so I guess it could be a week over week delta. 

 

LocationMemory Size (GB)Memory Utilization (%)Date
DAL1535.53076244.997333279/8/2021
DAL383.795471244.087083189/8/2021
HWT95.9745877655.965003129/8/2021
HWT1535.82161569.093890729/8/2021
HWT143.974639977.556666069/8/2021
AND14074.4334880.006026669/8/2021
BAL1103.79547127.958333339/8/2021
BAL383.795562758.705834079/8/2021
BAL319.68950480.414443979/8/2021
BAL639.481704770.468124399/8/2021
AND767.244242441.180000319/8/2021
AND767.61484143.107453529/8/2021
LEN2552.82339556.976834629/8/2021
DAL1535.53076245.336999519/15/2021
DAL383.795471244.345001229/15/2021
HWT95.9745864955.764996859/15/2021
HWT1535.82165568.086999519/15/2021
HWT143.974639985.849998479/15/2021
AND14074.4335680.065633669/15/2021
BAL1103.79547127.378333419/15/2021
BAL383.795562759.246251119/15/2021
BAL319.689498983.049999249/15/2021
BAL639.4817264.119999899/15/2021
AND767.614908940.745002759/15/2021
LEN2552.82336456.568889629/15/2021
HWT95.9745864954.580000569/22/2021
HWT95.9745864937.135002149/29/2021
HWT95.9745864956.0799992910/6/2021
HWT1535.82165570.061667129/22/2021
HWT1535.82165568.85999879/29/2021
HWT1535.82165568.3450012210/6/2021
DAL1535.53077245.247999579/22/2021
DAL1535.53076250.110000619/29/2021
DAL1535.53076244.4299995410/6/2021
AND767.244232240.057500849/22/2021
AND767.244232235.919998179/29/2021
AND767.244232242.7299995410/6/2021
BAL383.795562759.643333449/22/2021
BAL319.689509182.804997769/22/2021
BAL639.481714944.116249889/22/2021
LEN2552.82336456.6480005910/6/2021

 

 

LocationMemory Utilization %Delta
9/8/20219/15/20221
Dal 456025%
Len7270-3%
HWT222821%
BAL435826%
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Daryn-TP , Try a measure like

 

Change % =
var _date = maxx(filter(allselected(Table), [Location] = max(Table[Location]) && Table[Date] < Max(Table[Date])), [Date]) //Use all('Table') if one date is selected
return
Sum(Table[Memory Size]) - calculate(Sum(Table[Memory Size]),filter(allselected(Table) , [Location] = max(Table[Location]) && Table[Date] = _date))

 

use all in place allselected if needed

 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Daryn-TP , Try a measure like

 

Change % =
var _date = maxx(filter(allselected(Table), [Location] = max(Table[Location]) && Table[Date] < Max(Table[Date])), [Date]) //Use all('Table') if one date is selected
return
Sum(Table[Memory Size]) - calculate(Sum(Table[Memory Size]),filter(allselected(Table) , [Location] = max(Table[Location]) && Table[Date] = _date))

 

use all in place allselected if needed

 

So thankyou for the response @amitchandak 

 

I tried the suggested DAX and I get an error message, "The function SUM cannot work with values of type String"

 

The dax I used is below. So in my actual datset the table is called "Virt-Data", DC=location, Meeting Date = Date. I substituted these terms into your suggested DAX. 

Change % =
var _date = maxx(filter(allselected('Virt-Data'), [DC] = max('Virt-Data'[DC]) && 'Virt-Data'[Meeting Date] < Max('Virt-Data'[Meeting Date])), 'Virt-Data'[Meeting Date]) //Use all('Table') if one date is selected
return
Sum('Virt-Data'[Memory Utilization (%)]) - calculate(Sum('Virt-Data'[Memory Utilization (%)]),filter(allselected('Virt-Data') , 'Virt-Data'[DC] = max('Virt-Data'[DC]) && 'Virt-Data'[Meeting Date] = _date))
 
Not sure if I messed up the syntax when substituting terms though. 

Nevermind I figured it out I had one of my parameters set as an alphanumeric rather than a number. Thank you!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.