Here you go. Three drop-in files for C:\Dev\PowerBI_Date\.
# PowerBI_Date – Changelog
## 2025-11-02
- Added batch export of DAX measures from DAX Studio.
- Created merged catalog:
- 2025_11_AllMeasures_withTable.csv
- 2025_11_AllMeasures.dax
- Measure count: 365.
- Blank expressions: 6 placeholders skipped in .dax.
- Added repeatable merge script pattern for CSV/TSV with auto delimiter detect.
- Standardized monthly file naming: YYYY_MM_*.
## 2025-10-31 to 2025-11-01
- Set up DAX Studio export workflow.
- Validated export formats in Excel and PowerShell.
- Defined table map DMV for TableID to TableName join.
- Agreed storage paths under C:\Dev\PowerBI_Date\DAX and ...\PowerBI_Date\DAX\Studio.
## 2025-10
- Organized Power BI visuals and queries by topic.
- Started monthly “13-month rolling� reporting pack.
- Began documentation for exports, QA, and backups.
# Project Summary
Purpose
- Keep a clean, versioned backup of Power BI measures and metadata.
- Support monthly reporting and quick recovery.
- Allow search, diff, and review of every measure.
What exists now
- 365 measures exported.
- 6 placeholders without expressions. Tracked in CSV. Omitted from .dax.
- Files:
- C:\Dev\PowerBI_Date\DAX\2025_11_AllMeasures_withTable.csv
- C:\Dev\PowerBI_Date\DAX\2025_11_AllMeasures.dax
Core workflow
1) Export measures and table map from DAX Studio.
2) Merge to a single CSV with TableName.
3) Build a .dax catalog for quick diff and re-use.
4) Track blanks and fix them in the model.
Status to fix
- Fill or delete these placeholders:
- ATS_Court_Data: Measure
- ATS_Court_Data: Measure 3
- ATS_Court_Data: Report Month End := EOMONTH( TODAY(), -1 )
- ATS_Court_Data: Measure 4
- SSOCC_Data: Service Category Month Over Month
- Table: Measure 2
Naming
- Use YYYY_MM prefix on every monthly export.
- Keep CSV and DAX pairs in C:\Dev\PowerBI_Date\DAX.
- Keep raw DAX Studio exports in C:\Dev\PowerBI_Date\DAX\Studio.
Quick QA
```powershell
# count measures
Import-Csv 'C:\Dev\PowerBI_Date\DAX\2025_11_AllMeasures_withTable.csv' | Measure-Object
# list blanks
Import-Csv 'C:\Dev\PowerBI_Date\DAX\2025_11_AllMeasures_withTable.csv' |
? { -not $_.DaxExpression } |
Select TableName, MeasureName, DisplayFolder | ft -Auto
# README.md
Overview
- Stores monthly exports for Power BI models.
- Focus on measures, table map, and quick QA.
- Lives at C:\Dev\PowerBI_Date and C:\Dev\PowerBI_Date\DAX.
Folder layout
- C:\Dev\PowerBI_Date\DAX\Studio … raw exports from DAX Studio
- C:\Dev\PowerBI_Date\DAX … merged CSV and .dax catalogs
- C:\Dev\PowerBI_Date\mCode … Power Query M code exports organized by month and category
Monthly workflow
-
Export from DAX Studio
- Open PBIX in Power BI Desktop.
- Connect with DAX Studio.
- Results menu. File. CSV.
- Save to C:\Dev\PowerBI_Date\DAX\Studio.
Queries:
-
Measures
SELECT [TableID], [Name] AS MeasureName, [Expression] AS DaxExpression, [Description], [DisplayFolder], [FormatString] FROM $SYSTEM.TMSCHEMA_MEASURES; -
Table map
SELECT [ID] AS TableID, [Name] AS TableName FROM $SYSTEM.TMSCHEMA_TABLES;
Export settings
- Encoding: UTF-8.
- Include headers: on.
- Quote text: on.
- Delimiter: comma or tab. Match the file name (.csv or .tsv).
-
Merge and build .dax
-
Copy the latest two files to C:\Dev\PowerBI_Date\DAX with YYYY_MM names.
-
Run the merge script (example below). It auto detects comma or tab.
-
Outputs:
- YYYY_MM_AllMeasures_withTable.csv
- YYYY_MM_AllMeasures.dax
-
-
QA
- Check counts and blanks.
- Fix blanks in the model when time allows.
- Re-export if you change measures.
One-shot PowerShell
$dest = 'C:\Dev\PowerBI_Date\DAX'
$src = 'C:\Dev\PowerBI_Date\DAX\Studio'
$stamp = (Get-Date -Format 'yyyy_MM')
# pick newest
$measSrc = Get-ChildItem $src -Filter '*AllMeasures.*' | Sort LastWriteTime -Desc | Select -First 1
$mapSrc = Get-ChildItem $src -Filter '*TableMap.*' | Sort LastWriteTime -Desc | Select -First 1
Copy-Item $measSrc.FullName "$dest\$stamp`_AllMeasures$($measSrc.Extension)" -Force
Copy-Item $mapSrc.FullName "$dest\$stamp`_TableMap$($mapSrc.Extension)" -Force
function Import-SmartCsv($p){ $line = Get-Content $p -TotalCount 1; $d = ($line -like '*`t*') ? "`t" : ','; Import-Csv $p -Delimiter $d }
$meas = Import-SmartCsv "$dest\$stamp`_AllMeasures$($measSrc.Extension)"
$map = Import-SmartCsv "$dest\$stamp`_TableMap$($mapSrc.Extension)"
# normalize
$meas = $meas | Select `
@{n='TableID';e={ $_.TableID -as [string]}},
@{n='MeasureName';e={ $_.MeasureName ? $_.MeasureName : $_.Name }},
@{n='DaxExpression';e={ $_.DaxExpression ? $_.DaxExpression : $_.Expression }},
Description, DisplayFolder, FormatString
$map = $map | Select `
@{n='TableID';e={ $_.TableID ? $_.TableID : $_.ID }},
@{n='TableName';e={ $_.TableName ? $_.TableName : $_.Name }} |
? { $_.TableID -and $_.TableName }
# join
$lk=@{}; $map | % { if(-not $lk.ContainsKey($_.TableID)){ $lk[$_.TableID]=$_.TableName } }
$meas | % { $_ | Add-Member TableName ($lk[$_.TableID]) -Force }
# save merged
$merged = "$dest\$stamp`_AllMeasures_withTable.csv"
$meas | Export-Csv $merged -NoTypeInformation -Encoding UTF8
# build .dax
$sb = New-Object Text.StringBuilder
$meas | ? { $_.DaxExpression } | % {
$t = $_.TableName ? $_.TableName : "_TableId_$($_.TableID)"
$null = $sb.AppendLine("// $t\$($_.MeasureName)")
$null = $sb.AppendLine("[$($_.MeasureName)] = $($_.DaxExpression)")
$null = $sb.AppendLine()
}
$outDax = "$dest\$stamp`_AllMeasures.dax"
[IO.File]::WriteAllText($outDax, $sb.ToString(), [Text.Encoding]::UTF8)
# summary
"Rows: $($meas.Count)"
"Expr blanks: $(( $meas | ? { -not $_.DaxExpression }).Count)"
"Saved: $merged"
"Saved: $outDax"Troubleshooting
-
DMV query fails in DAX Studio
- Make sure the tab is in DMV mode. Open DMV pane. Double click the DMV. You should see
SELECT * FROM $SYSTEM....
- Make sure the tab is in DMV mode. Open DMV pane. Double click the DMV. You should see
-
Excel shows a single column on import
- Pick the right delimiter. Comma for .csv. Tab for .tsv.
-
Line breaks inside DAX
- Keep UTF-8 and quoted text on export.
Checklist each month
- Export measures and table map.
- Run the merge script.
- Confirm counts.
- Review blanks. Fix if needed.
- Commit the two outputs to version control.
If you want, I can add a tiny `Run-Exports.cmd` that calls the PowerShell block with one double-click.
::contentReference[oaicite:0]{index=0}
- Run DMV queries in DAX Studio.
- Export to TSV with headers and quotes.
- Run the merge script to create Joined CSV and DAX.
- Run tools\organize_dax_studio.ps1 to file by month.
- Review INDEX.md and SUMMARY.md.
- Commit and push.
Automated Processing: Export CSV files from Power BI monthly reports directly to _DropExports\ folder, then run the automation script.
Quick Start:
- Export all CSV files from Power BI monthly reports
- Save them to
C:\Dev\PowerBI_Date\_DropExports\ - Run:
.\tools\organize_backfill_exports.ps1 - Files are automatically categorized, moved, renamed, and manifest updated
What the script does:
- Auto-detects current month (or specify with
-Month) - Categorizes files by filename keywords (arrest, traffic, detectives, etc.)
- Moves files to correct category folders in
Backfill\YYYY_MM\ - Adds
YYYY_MM_prefix to all filenames - Updates
manifest.jsonautomatically
Manual Workflow (Alternative):
- Export CSV files and place in appropriate
Backfill\YYYY_MM\[category]\folders - Run
.\tools\rename_backfill_files.ps1 -Month "YYYY_MM" -Folder "Backfill\YYYY_MM" - Run
.\tools\update_backfill_manifest.ps1 -Folder "Backfill\YYYY_MM"
Documentation:
Backfill/QUICK_START.md- Quick reference guideBackfill/BACKFILL_WORKFLOW.md- Complete workflow documentation
Status:
- October 2025: 34 files processed and organized
- November 2025: Folder structure ready, awaiting exports
Current Status: Automated extraction tools have limitations with newer .pbix format. Manual export is recommended.
Recommended Method: Manual Export from Power Query Editor
- Open Power BI Desktop with your
.pbixfile. - Open Power Query Editor (Home → Transform Data).
- For each query:
- Click the query
- View → Advanced Editor (or Home → Advanced Editor)
- Copy the M code
- Save as
QueryName.minmCode\YYYY_MM\
- Organize files with
tools\organize_mcode_from_helper.ps1
Folder structure: mCode\YYYY_MM\ organized by category (arrest, nibrs, detectives, etc.)
Alternative methods explored:
pbi-toolsv1.2.0 - Does not support direct.pbixextraction- Tabular Editor 2.x - M code not exposed via TOM API when connected to Power BI Desktop
- Direct
.pbixZIP extraction - M code stored in binary format in newer TMDL-based.pbixfiles
Documentation:
tools/export_mcode_manual_guide.md- Detailed manual export guidetools/export_mcode_with_tabular_editor.md- Tabular Editor method (limited functionality)docs/MCODE_EXPORT_GUIDE.md- Complete M code export guide with all methods
All scripts and exports now use C:\Dev\PowerBI_Date as the root directory. DAX exports are organized under:
- DAX\Studio\YYYY_MM\ - Raw DAX Studio exports (TSV/CSV)
- DAX\ - Processed exports (AllMeasures_withTable.csv, AllMeasures.dax)
Repository: https://github.com/racmac57/Power_BI_Data
# Use the idempotent script
powershell -ExecutionPolicy Bypass -File C:\Dev\PowerBI_Date\tools\git_push_direct.ps1
# Or manually
cd C:\Dev\PowerBI_Date
git add -A
git commit -m "Your message"
git pushAfter completing monthly exports, create a version tag:
git tag -a v2025_12 -m "December 2025 DAX exports"
git push origin v2025_12Automated workflow with linting, validation, and releases:
# Create monthly tag (triggers workflow)
powershell -ExecutionPolicy Bypass -File tools\tag_month.ps1What happens:
- Lints PowerShell scripts with PSScriptAnalyzer
- Validates DAX export structure
- Generates measures diff report
- Creates GitHub Release with artifacts
View: https://github.com/racmac57/Power_BI_Data/actions
Centralized Automation Hub: For Python ETL scripts that process data for Power BI.
A master automation system is available at:
C:\Users\carucci_r\OneDrive - City of Hackensack\Master_Automation\
Features:
- Run all Python ETL scripts from one location
- Sequential execution in configured order
- Automatic Power BI integration (copies outputs to
_DropExports\) - Comprehensive logging and error handling
- Configurable via
config\scripts.json
Usage:
cd "C:\Users\carucci_r\OneDrive - City of Hackensack\Master_Automation"
.\scripts\run_all_etl.ps1Pre-configured Scripts: Arrests, Community Engagement, Overtime TimeOff, Policy Training, Response Times, Summons, NIBRS, and more.
Documentation:
docs/MASTER_AUTOMATION_GUIDE.md- Complete guideMaster_Automation/README.md- Full documentationMaster_Automation/QUICK_START.md- Quick reference
- MONTHLY_WORKFLOW.md - Complete monthly DAX export process
- Backfill/QUICK_START.md - Quick guide for monthly CSV exports
- Backfill/BACKFILL_WORKFLOW.md - Complete backfill workflow
- docs/MASTER_AUTOMATION_GUIDE.md - Master ETL automation guide
- docs/PYTHON_WORKSPACE_AI_GUIDE.md - AI guidance for Python workspaces
- docs/GITHUB_SETUP.md - GitHub setup and branch protection
- docs/GITHUB_ACTIONS_SETUP.md - CI/CD details
.gitattributesensures CSV/TSV/DAX files have readable diffs.gitignoreexcludes logs and ad-hoc dumps, keeps organized monthly folders
Latest DAX export: 2025_11 (359 measures, 0 blanks) Latest Backfill: October 2025 (34 CSV files organized)