I hope this is the proper forum for this request.
I am struggling with an incorrect result from a DAX Calculated measure using Excel 2013 and Power Pivot. The measure that works, but results in an incorrect answer is as follows:
PriorCount:=
CALCULATE (
COUNTROWS ( EquipmentList ),
EquipmentList[InServiceDate] <> BLANK (),
FILTER (
VALUES ( EquipmentList[InServiceDate] ),
EquipmentList[InServiceDate] <= [PriorEndDate]
),
FILTER (
VALUES ( EquipmentList[SoldDate] ),
OR (
EquipmentList[SoldDate] > [PriorEndDate],
EquipmentList[SoldDate] = BLANK ()
)
)
)
(Thank you DAX Formatter)
The measure [PriorEndDate] appears to be the culprit. In the context from the Power Pivot table where this is used, the user selects a date range on a Timeline Slicer. Depending on the selection, [PriorEndDate] is either :
PriorPeriodMonth:=
LASTDATE (
DATEADD (
DateDimension[Date],
[SlicerMonthCount] * [SlicerInterval],
MONTH
)
)
or
PriorPeriodYear:=
LASTDATE ( DATEADD ( DateDimension[Date], -1, YEAR ) )
as determined by :
PriorEndDate:=SWITCH (
[SwitchValue],
0, [PriorPeriodMonth],
1, [PriorPeriodYear]
)
The best I can figure out is that the Calculate function in [PriorCount] is losing the Pivot Table context in some manner. With the current data I am using, the value for [PriorEndDate] when the current year to date is selected should be 7/31/2014 and return a count of 137. However, [PriorCount] is returning a count of 129 which is the value for 12/31/2014.
I am sure this is not the clearest explanation. Bottom line is the user selects current YTD and should see data for the previous YTD in the same period, not for the full previous year.
Any thoughts would be appreciated.
Thank you
I am struggling with an incorrect result from a DAX Calculated measure using Excel 2013 and Power Pivot. The measure that works, but results in an incorrect answer is as follows:
PriorCount:=
CALCULATE (
COUNTROWS ( EquipmentList ),
EquipmentList[InServiceDate] <> BLANK (),
FILTER (
VALUES ( EquipmentList[InServiceDate] ),
EquipmentList[InServiceDate] <= [PriorEndDate]
),
FILTER (
VALUES ( EquipmentList[SoldDate] ),
OR (
EquipmentList[SoldDate] > [PriorEndDate],
EquipmentList[SoldDate] = BLANK ()
)
)
)
(Thank you DAX Formatter)
The measure [PriorEndDate] appears to be the culprit. In the context from the Power Pivot table where this is used, the user selects a date range on a Timeline Slicer. Depending on the selection, [PriorEndDate] is either :
PriorPeriodMonth:=
LASTDATE (
DATEADD (
DateDimension[Date],
[SlicerMonthCount] * [SlicerInterval],
MONTH
)
)
or
PriorPeriodYear:=
LASTDATE ( DATEADD ( DateDimension[Date], -1, YEAR ) )
as determined by :
PriorEndDate:=SWITCH (
[SwitchValue],
0, [PriorPeriodMonth],
1, [PriorPeriodYear]
)
The best I can figure out is that the Calculate function in [PriorCount] is losing the Pivot Table context in some manner. With the current data I am using, the value for [PriorEndDate] when the current year to date is selected should be 7/31/2014 and return a count of 137. However, [PriorCount] is returning a count of 129 which is the value for 12/31/2014.
I am sure this is not the clearest explanation. Bottom line is the user selects current YTD and should see data for the previous YTD in the same period, not for the full previous year.
Any thoughts would be appreciated.
Thank you