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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
benduke99
New Member

Trying to get the last value into a column

Hello, 

I am currently trying to manipulate some data I pull from FRED. 

 

The data looks like this, it is a very large data source so this is a small snippet, there are even more Index Names: 

 

DateYearMonthNameIndex NameValue
10/31/20232023OctoberGlobal Price Soft Logs208
9/30/20232023SeptemberGlobal Price Energy202.9
8/31/20232023OctoberGlobal Price WTI Crude85.47
7/31/20232023NovemberGlobal Price Tin24501
6/30/20232023DecemberGlobal Price Wool Coarse835.9
5/31/20232023JanuaryGlobal Price Wool Fine894.1
4/30/20232023FebruaryGlobal Price Industrial Materials157.6
3/31/20232023MarchGlobal Price Nickel18264
2/28/20232023AprilGlobal Price Cotton95.69
1/31/20232023MayGlobal Price Metal180.2
12/31/20222022JuneDeep Sea Freight410.1
11/30/20222022JulyGlobal Price Rubber73.2
10/31/20222022AugustGlobal Price Aluminum2194
9/30/20222022SeptemberGlobal Price Copper7941
8/31/20222022OctoberGlobal Price All Commodities167.8
7/31/20222022NovemberWood Office Furn Mfg270.7
6/30/20222022DecemberGeneral Freight Trucking172.5
5/31/20222022JanuaryWood Bedroom Furn Not Custom Mfg361.5
4/30/20222022FebruaryRail Freight230.9
3/31/20222022MarchConstruction Employees8033
2/28/20222022AprilCanadian Dollar to U.S. Dollar Spot Exchange Rate1.388

 

The data goes all the way back to when FRED started reporting on all these different indicis, commodities, prices, etc. 

 

What I want to do is add a column that has the Value from the previous month for the specific index, commodity, etc. 

 

Seems like it would be so simple but I have been tooling around with this and cannot find a solution (I am really new to DAX). 

 

At the end of the excercie I want to get to the % change from month to month but being in a table is important to my stakeholder, while I recognize a measure can probably do this, I need to be able to provide the table. 

 

Ideally the output would look like this:

 

DateYearMonthNameIndex NameValueLast Months Value%Change
10/31/20232023OctoberGlobal Price Soft Logs208XXXXXX
9/30/20232023SeptemberGlobal Price Energy202.9XXXXXX
8/31/20232023OctoberGlobal Price WTI Crude85.47XXXXXX
7/31/20232023NovemberGlobal Price Tin24501XXXXXX
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @benduke99 ,

 

not sure if i fully get you, supposing you have a data table like:

Date Index Value
11/1/2022 a 1
12/1/2022 a 1
12/2/2022 a 1
1/1/2023 a 3
2/1/2023 a 4
11/1/2022 b 4
12/1/2022 b 3
1/1/2023 b 2
2/1/2023 b 1

 

try to

1) add two calculated columns like:

Month = FORMAT([Date], "YY/MM")
MonthSN = YEAR([Date])*12+MONTH(data[Date]) 

 

2) plot a table visual with index and month columns and measures like:

ValueSum = SUM(data[Value])
MonthlyChange = 
VAR _pre = 
CALCULATE(
    [ValueSum], 
    data[MonthSN] = MAX(data[MonthSN]) - 1,
    ALL(data[Month]) 
)
VAR _result = [ValueSum] - _pre
RETURN _result
MonthlyChange% = DIVIDE([MonthlyChange], [ValueSum])

 

it worked like:

FreemanZ_0-1699929142150.png

 

 

 

 

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @benduke99 ,

 

not sure if i fully get you, supposing you have a data table like:

Date Index Value
11/1/2022 a 1
12/1/2022 a 1
12/2/2022 a 1
1/1/2023 a 3
2/1/2023 a 4
11/1/2022 b 4
12/1/2022 b 3
1/1/2023 b 2
2/1/2023 b 1

 

try to

1) add two calculated columns like:

Month = FORMAT([Date], "YY/MM")
MonthSN = YEAR([Date])*12+MONTH(data[Date]) 

 

2) plot a table visual with index and month columns and measures like:

ValueSum = SUM(data[Value])
MonthlyChange = 
VAR _pre = 
CALCULATE(
    [ValueSum], 
    data[MonthSN] = MAX(data[MonthSN]) - 1,
    ALL(data[Month]) 
)
VAR _result = [ValueSum] - _pre
RETURN _result
MonthlyChange% = DIVIDE([MonthlyChange], [ValueSum])

 

it worked like:

FreemanZ_0-1699929142150.png

 

 

 

 

This is exaclty what I was looking for!

 

Appreciate your help!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.