Creating Measure in Date Table for Current Month, Previous Month, etc.

CSMcVey

New Member
Joined
Oct 30, 2012
Messages
21
I have a date table I am importing into a PowerPivot workbook. This data table contains a column entitled, 'date' which has a date for every day from 2000 to 2020. It has other basic columns like month name, month number, year, day, business day flag, etc.

I would like to create a measure which looks @ another measure called 'LastDate' (this identifies the last.max date in my data set) and then sets the measure to one of 5 values:


  1. Current Month
  2. Current Month -1 (aka Previous Month)
  3. Current Month -2
  4. Current Month -3
  5. Current Month -4+ (the rest)

For example if the LastDate was equal to 3/13/13:


  1. all dates in my date table where the Month is March and the Year is 2013 would have this new measure be equal to 'Current Month'
  2. all dates in my date table where the Month is Feb and the Year is 2013 would have this new measure be equal to 'Current Month -1'
  3. all dates in my date table where the Month is Jan and the Year is 2013 would have this new measure be equal to 'Current Month -2'
  4. all dates in my date table where the Month is Dec and the Year is 2012 would have this new measure be equal to 'Current Month -3'
  5. all dates in my date table where the date is earlier than Dec 2012 would have this new measure be equal to 'Current Month -4+'

The part I am struggling with are the months that involve a year change.

Thanks in advance
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,223,943
Messages
6,175,546
Members
452,652
Latest member
eduedu

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