DAX PIVOT: Projects Closure Date Field - Number of Days Change - between differing Forecast Versions

phil134

New Member
Joined
Apr 10, 2018
Messages
3
Hi, I'm new to DAX, but I'm sure the solution here should be relatively easy? Any elegant solution gratefully received. I need to be able to report where, between 2 Forecast versions, the Closure date for a Project has slipped (or accelerated). I've used 'Calculated Items' within an ordinary Pivot but there are drawbacks within it. Perhaps DAX can help?

SOLUTION REQUIRED & NATURE OF DATA
I need my Pivot to only have 3 columns: Project Closure Date (Period A forecast), Project Closure Date (Period B forecast); Days difference (and where I can use the Pivot to filter out Days difference = '0'; and where the calculation returns a message if the Closure Date was Blank in one column, so the calculation is invalid)

I have Unpivoted Excel data, one row for for each Project/Month. Each row has columns showing
- STRING: Project Code
- NUMBER: the Efficiency Project forecast £ monetary saving that month (varies)
- DATE: the Project's Closure date (repeated on each row)
- STRING: The forecast Version number (eg P6 = Period 6, P10 = Period 10) Each month's forecast has around 25k rows of data (around 1,200 Projects, so, on average, 21 unique month rows for each project).

**RAW DATA FORMAT**: - I've uploaded an image to this post. This is an excerpt of data (showing historic Projects for data protection purposes). I have appended just 2 Forecasts (i.e. Versions) for visual simplicity. I can either Append each month's forecast on 1 Data Table or have separate data tables in the Data Model for each month's forecast (version).

CONSIDERATIONS are:
a) I can't use DATE DIFF: as I'm comparing dates in the same underlying data field ('Closure'), not 2 different underlying date fields (eg. Invoice posted date, Invoice paid date).
b) 'Closure' date is repeated on several rows for each Project
c) Varied Data Types: (DATES and NUMBER (for number of days variance in date)
d) Multiple Forecasts: My raw data uploaded shows just 2 Lots of data (Period 6 and Period 10 forecasts, each of around 25k rows of data). However, I'd like to be able to dynamically vary which Periods that I compare, up to say between 10 to 15 "versions".

ATTEMPTS SO FAR & ISSUES:

1. PIVOT WITHOUT DAX (using 'Calculated Items'):
- Method: I put a new column in the underlying data to identify the first data line of each Project, so I only have 1 Date cell, avoiding the need to use the AVERAGE function (which doesn't work when then using 'Calculated items')
- Problems 1: I can't filter on the 'Calculated Items' Field (Days variance) - is that just me?
- Problem 2: The Pivot 'Value Field settings' makes all 3 columns in the pivot be either in DATE format (not suitable for Days Variance column), or NUMBER format (not suitable Closure Dates columns by Version)

2. DAX PIVOT
I can't get the correct code for the variance. It subtracts the same Version Closure Date away from itself, so resolves to Zero.

Thanks!!!
 

Attachments

  • ClosureDateDiff_Raw Data example.JPG
    ClosureDateDiff_Raw Data example.JPG
    52 KB · Views: 11
  • CloseDateDiff_CalculatedItemMethod.JPG
    CloseDateDiff_CalculatedItemMethod.JPG
    53.4 KB · Views: 8
  • ClosureDateDiff_DAXcodeattempted.JPG
    ClosureDateDiff_DAXcodeattempted.JPG
    43.1 KB · Views: 10
  • ClosureDateDiff_DAXpivotNotSatisfactory.JPG
    ClosureDateDiff_DAXpivotNotSatisfactory.JPG
    41.3 KB · Views: 9

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,223,884
Messages
6,175,173
Members
452,615
Latest member
bogeys2birdies

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