Relate Data to last Month

FlashFire

New Member
Joined
Jun 16, 2016
Messages
10
I've been trying to create a formula to relate data to the last month in DAX. Nothing I've found or created has worked.

What I've Tried:

CALCULATE(
SUM('Data Warehouse'[EXT AMOUNT]),
--VALUES('Data Warehouse'[EXT AMOUNT]),
----------
--PREVIOUSMONTH(ALL('Dates'[Dates]))
PARALLELPERIOD(ALL('Dates'[Dates]),-1,MONTH)
--DATEADD('Data Warehouse'[Sale.Invoice Date],-1,DAY)
--DATEADD(DATESMTD('Data Warehouse'[Sale.Invoice Date]),-1,MONTH)
--FILTER(
-- ALL('Dates'[Dates]),
-- EARLIER('Dates'[Index]) = 'Dates'[Index]-30
--)
)

I've tried all of these. The only one that doesn't return blank data is PARALLELPERIOD, and it returns the same data as EXT AMOUNT.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Assuming you have a separate Calendar table marked as Date Table, Calendar table linked to Data Warehouse via Dates[Date] field, and power pivot is setup to filter to current period, then should be just:

Code:
[COLOR=#333333]CALCULATE( [/COLOR][COLOR=#333333]SUM('Data Warehouse'[EXT AMOUNT]),[/COLOR][COLOR=#333333]PREVIOUSMONTH( 'Dates'[Dates] ) )[/COLOR]
 
Upvote 0
Assuming you have a separate Calendar table marked as Date Table, Calendar table linked to Data Warehouse via Dates[Date] field, and power pivot is setup to filter to current period, then should be just:

Code:
[COLOR=#333333]CALCULATE( [/COLOR][COLOR=#333333]SUM('Data Warehouse'[EXT AMOUNT]),[/COLOR][COLOR=#333333]PREVIOUSMONTH( 'Dates'[Dates] ) )[/COLOR]

I'm using Power BI, not Power Pivot. I've created a relation between Data Warehouse and Dates already.

As far as I know, there isn't a setting to make a table a Date Table.

And the code provided does nothing. No error, No data displayed.
 
Upvote 0
Power BI doesn't have a Mark as Date and if you have linked the Date column from Calendar to Data Warehouse you shouldn't need Mark as Date anyway. Does your Calendar table include contiguous dates for all dates you want to report on (current and previous months)? what are you putting on rows/columns? Other filters?

Formula provided should work.
 
Upvote 0
Yes, the Calendar table does have contiguous dates. The columns in the table are Index, Day of Week, and Month. The only relation between Data warehouse and Dates is Invoice Date and Dates.

I made the Dates table in excel, and removed the single Null value. So it should be correct.
 
Upvote 0
What happens if you put "Months" on the rows and remove the "Index" and "Day of Week"? Does measure work?
 
Upvote 0

Forum statistics

Threads
1,215,361
Messages
6,124,497
Members
449,166
Latest member
hokjock

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top