PowerShell script to create Dates.csv file

Overview

CreateDatesFile.ps1 creates Dates.csv, the date table file used by Portfolio Slicer.

This file is one of the required external files loaded into the workbook.

Why This File Is Needed

Portfolio Slicer reports rely on a continuous date table for time-based analysis.

That means the workbook needs a file that contains:

  • one record per date
  • every date from MinDate up to today

This is much safer to generate automatically than to maintain by hand.

Inputs Used by the Script

The script normally reads:

  • MinDate from psConfig.txt
  • the target output folder from script configuration

MinDate is especially important. If it changes, Dates.csv needs to be rebuilt so the workbook date table still matches the rest of your setup.

Output

The script creates or refreshes:

  • Dates.csv

The file is normally created in the PSData folder and then loaded into Portfolio Slicer together with the other external data files.

What the Result Looks Like

The final file contains tab-separated values with a header.

Dates.csv example

Practical Notes

  • Dates.csv should start at the same MinDate used in your workbook Config table
  • if MinDate changes, rebuild the file
  • if Dates.csv is missing, many date-based reports will not refresh correctly