Forum Discussion
Userrelationship / ParrallelPeriod wrong subtotals
Hi all,
I have a problem with wrong subtotals in my calculations using Userrelationship / ParrallelPeriod.
The fact table contains cost information per employee and two date columns, date and source date (= snapshot date of data extraction).
Situation:
For my Solution I use this measure
For the PY:
Problem:
I am not sure what I do wrong. My best guess is that my filter argument with
Thanks for getting back to me. Unfortunately that was not working for me. In the meantime I did get help in another forum. My code missed a REMOVEFILTERS condition. Then it works fine:
MaxSourcedate =
VAR CY = 0
VAR Source =
CALCULATE(
MAX( WorkDay[SourceDate] ),
USERELATIONSHIP( WorkDay[SourceDate], 'Date'[Date] ) ,
PARALLELPERIOD('Date'[Date], CY, YEAR) ,REMOVEFILTERS ( 'WorkDay' )
)
VAR Result =
CALCULATE(
[Annual Pay],
FILTER(
ALL(WorkDay[SourceDate]),
WorkDay[SourceDate] = Source
)
)RETURN
Result
Thanks a lot anyway.
2 Replies
- amitchandak
Super User
MarcW , Try like
Var _measure = CALCULATE(
[Annual Pay] ,USERELATIONSHIP( WorkDay[SourceDate], 'Date'[Date] ) )
VAR Result =
CALCULATE(
_measure,
Dateadd('Date'[Date], -1, year)
)Have measure with userelationship and then use time intelligence
Check the last period formula in my Hr file, attached after signature
- MarcWFrequent Visitor
Thanks for getting back to me. Unfortunately that was not working for me. In the meantime I did get help in another forum. My code missed a REMOVEFILTERS condition. Then it works fine:
MaxSourcedate =
VAR CY = 0
VAR Source =
CALCULATE(
MAX( WorkDay[SourceDate] ),
USERELATIONSHIP( WorkDay[SourceDate], 'Date'[Date] ) ,
PARALLELPERIOD('Date'[Date], CY, YEAR) ,REMOVEFILTERS ( 'WorkDay' )
)
VAR Result =
CALCULATE(
[Annual Pay],
FILTER(
ALL(WorkDay[SourceDate]),
WorkDay[SourceDate] = Source
)
)RETURN
Result
Thanks a lot anyway.