cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Frequent Visitor

## 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

MaxSourcedate =

VAR CY = 0

VAR Source =
CALCULATE(
MAX( WorkDay[SourceDate] ),
USERELATIONSHIP( WorkDay[SourceDate], 'Date'[Date] ) ,
PARALLELPERIOD('Date'[Date], CY, YEAR)
)

VAR Result =
CALCULATE(
[Annual Pay],
FILTER(
ALL(WorkDay[SourceDate]),
WorkDay[SourceDate] = Source
)
)

RETURN

Result

For the PY:

MaxSourcedate PY =

VAR PY = -1

VAR SourcePY =
CALCULATE(
MAX( WorkDay[SourceDate] ),
USERELATIONSHIP( WorkDay[SourceDate], 'Date'[Date] ) ,
PARALLELPERIOD('Date'[Date], PY, YEAR)
)

VAR Result =
CALCULATE(
[Annual Pay],
FILTER(
ALL(WorkDay[SourceDate]),
WorkDay[SourceDate] = SourcePY
)
)

RETURN

Result

Problem:

I am not sure what I do wrong. My best guess is that my filter argument with

FILTER(
ALL(WorkDay[SourceDate]),
WorkDay[SourceDate] = SourcePY
gives back all values of the last sourcedate but then is not summing up in the totals. Has anyone an idea to fix that? Thanks in advance. 🙂

1 ACCEPTED SOLUTION
Frequent 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.

2 REPLIES 2
Super User

@MarcW , Try like

Var _measure = CALCULATE(
[Annual Pay] ,USERELATIONSHIP( WorkDay[SourceDate], 'Date'[Date] ) )

VAR Result =
CALCULATE(
_measure,
)

Have measure with userelationship and then use time intelligence

Check the last period formula in my Hr file, attached after signature

Frequent 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.

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Top Solution Authors
Top Kudoed Authors