Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
juliamacg_
Frequent Visitor

Help needed with AVERAGEX and USERELATIONSHIP - date slicer not working

Hello.

I have a table called FAT_REGISTRY on PBI with many rows regarding my company's contracts. It has many duplicates for CONTRACT_ID and other fields due to columns like UPDATE_DATE and others.

 

juliamacg__0-1712462988657.png

I need to have a measure that calculates the average task duration for each task and on account of the table's structure I used AVERAGEX for that. 

 

Completed Tasks Average Duration = 

CALCULATE(

    AVERAGEX(

        SUMMARIZECOLUMNS(FAT_REGISTRY[TASK_ID], FAT_REGISTRY[TASK_DURATION]),

        FAT_REGISTRY[TASK_DURATION]

    ),

    FAT_REGISTRY[TASK_COMPLETION_DATE] <> BLANK(),

   USERELATIONSHIP(DIM_CALENDARIO[Date],FAT_REGISTRY[TASK_COMPLETION_DATE])

)
 
The USERELATIONSHIP part is there because DIM_CALENDARIO[Date] is the field I use in all slicers. I actually know it's set alright because I used that same relationship in many other measures and in them the USERELATIONSHIP function is working fine.

juliamacg__1-1712463394578.png

However in the aforementioned measure it is not. When I plot it in a chart it shows me the result for the whole table instead of applying the date filter I select in the slicer. It is not affected by it at all.

juliamacg__2-1712463688390.png

 

I'm lost here. What should I change in the measure for it to work?

1 ACCEPTED SOLUTION
tharunkumarRTK
Super User
Super User

@juliamacg_ 
I woudl suggest you to try this pattern:

Completed Tasks Average Duration = 

CALCULATE(

    AVERAGEX(

       VALUES(FAT_REGISTRY[TASK_ID]),

        calculate(Sum(FAT_REGISTRY[TASK_DURATION]))

    ),

    FAT_REGISTRY[TASK_COMPLETION_DATE] <> BLANK(),

   USERELATIONSHIP(DIM_CALENDARIO[Date],FAT_REGISTRY[TASK_COMPLETION_DATE])

)

 

And regarding the issue with USERELATIONSHIP function, would it be possible for you share the sample file?

 

View solution in original post

2 REPLIES 2
tharunkumarRTK
Super User
Super User

@juliamacg_ 
I woudl suggest you to try this pattern:

Completed Tasks Average Duration = 

CALCULATE(

    AVERAGEX(

       VALUES(FAT_REGISTRY[TASK_ID]),

        calculate(Sum(FAT_REGISTRY[TASK_DURATION]))

    ),

    FAT_REGISTRY[TASK_COMPLETION_DATE] <> BLANK(),

   USERELATIONSHIP(DIM_CALENDARIO[Date],FAT_REGISTRY[TASK_COMPLETION_DATE])

)

 

And regarding the issue with USERELATIONSHIP function, would it be possible for you share the sample file?

 

@tharunkumarRTK I tried your solution but the numbers turned out huge, so I changed the SUM part into AVERAGE and it worked!

 

Completed Tasks Average Duration = 

CALCULATE(

    AVERAGEX(

       VALUES(FAT_REGISTRY[TASK_ID]),

        CALCULATE(AVERAGE(FAT_REGISTRY[TASK_DURATION]))

    ),

    FAT_REGISTRY[TASK_COMPLETION_DATE] <> BLANK(),

   USERELATIONSHIP(DIM_CALENDARIO[Date],FAT_REGISTRY[TASK_COMPLETION_DATE])

)

 

Thanks so much!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.