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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
efstel
Helper I
Helper I

USERELATIONSHIP with Filters

I currently am using the following with an active relationship between my Date Table and the OpportunitiesView. (The Date Table is connected to my SortMonth Table in order to keep the months in chronologic order.) I'm calculating the monthly running totals for each year.   

 
ClosedWon running total in Month 2024 =
CALCULATE(
    SUM(OpportunitiesView[ClosedWon]),
    FILTER(
        CALCULATETABLE(
            SUMMARIZE('SortMonth', 'SortMonth'[Sort], 'SortMonth'[Month]),
            ALLSELECTED('SortMonth')
        ),
        ISONORAFTER(
            'SortMonth'[Sort], MAX('SortMonth'[Sort]), DESC,
            'SortMonth'[Month], MAX('SortMonth'[Month]), DESC
        )
    ),
        FILTER(
            ALLSELECTED('Calendar'),
            'Calendar'[Date] <= MAX('Calendar'[Date]) && YEAR('Calendar'[Date]) = 2024
        )
    )
 
I want to USERELATIONSHIP between ('Calendar'[Date], OpportunitiesView[CloseDate]),

I believe it needs to go after the SUM function and before the first FILTER function, but that isn’t working. 

 

What am I doing wrong?

 

Thanks!

1 ACCEPTED SOLUTION
v-nuoc-msft
Community Support
Community Support

 Hi @efstel 

 

Allow me to confirm a few questions for you:


1. Relationship Activation: Ensure that the relationship between Calendar[Date] and OpportunitiesView[CloseDate] is correctly defined and inactive by default.

 

2. Data Context: Verify that the data in OpportunitiesView and Calendar tables are correctly populated and that there are no missing or incorrect dates.

 

3. SortMonth Table: Confirm that the SortMonth table is correctly set up and that the Sort and Month columns are properly defined.

 

By adding USERELATIONSHIP('Calendar'[Date], OpportunitiesView[CloseDate]) within the CALCULATE function, it should correctly activate the relationship for your calculation.

 

After the above questions are confirmed, bhanu_gautam's reply should be effective.

 

If you still have problems, it is best to provide the pbix file and be careful to delete sensitive data.

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
v-nuoc-msft
Community Support
Community Support

 Hi @efstel 

 

Allow me to confirm a few questions for you:


1. Relationship Activation: Ensure that the relationship between Calendar[Date] and OpportunitiesView[CloseDate] is correctly defined and inactive by default.

 

2. Data Context: Verify that the data in OpportunitiesView and Calendar tables are correctly populated and that there are no missing or incorrect dates.

 

3. SortMonth Table: Confirm that the SortMonth table is correctly set up and that the Sort and Month columns are properly defined.

 

By adding USERELATIONSHIP('Calendar'[Date], OpportunitiesView[CloseDate]) within the CALCULATE function, it should correctly activate the relationship for your calculation.

 

After the above questions are confirmed, bhanu_gautam's reply should be effective.

 

If you still have problems, it is best to provide the pbix file and be careful to delete sensitive data.

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

I can confirm the above. It is working now. For whatever reason, the numbers were not matching up with my raw data. May have been user error. I may not have updated my dataset when I was checking them. 

bhanu_gautam
Super User
Super User

@efstel , Try using below DAX

 

ClosedWon running total in Month 2024 =
CALCULATE(
SUM(OpportunitiesView[ClosedWon]),
USERELATIONSHIP('Calendar'[Date], OpportunitiesView[CloseDate]),
FILTER(
CALCULATETABLE(
SUMMARIZE('SortMonth', 'SortMonth'[Sort], 'SortMonth'[Month]),
ALLSELECTED('SortMonth')
),
ISONORAFTER(
'SortMonth'[Sort], MAX('SortMonth'[Sort]), DESC,
'SortMonth'[Month], MAX('SortMonth'[Month]), DESC
)
),
FILTER(
ALLSELECTED('Calendar'),
'Calendar'[Date] <= MAX('Calendar'[Date]) && YEAR('Calendar'[Date]) = 2024
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thanks @bhanu_gautam, but if you notice in my request above, that is exactly how I put it in as you have proposed. It is not working properly.  

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.