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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
VVI
Frequent Visitor

Visual using USERELATIONSHIP

Hi all,

 

I'm trying to create a simple column chart as follow

VVI_0-1675407067417.png

 

with 2 tables: Calendar Date and Contract table.

I have 2 date relationships between both tables, by using Date column in Calendar Date table  with one active relationship with Contract Active Date and another inactive one with Contract End Date, from Contract table.

For this visual, I need to use Contract End Date in the DAX formula.

And I'd like to use Month column from Calendar Date, for easier interaction with other visuals.

But it's not as expected.

VVI_1-1675411174742.png

 

When I'm using Month from Contract End Date, the visual is correct though.

This is the DAX I used. I'm not sure which one is wrong, and hope to get help.

Value of Contract Expected to be Ended =
var _CurrentProdDate =
    CALCULATE(
        MAXX(
            Production,
            Production[Date]
            ),
        ALL( 'Calendar Date'[Date] ),
        Production[Status]
            = "Being Processed"
    )

var _ContractToBeEnded =
    SUMX (
        VALUES ( Contract[Customer] ),
        CALCULATE (
            MAX ( Contract[Annual Contract Value] ),
            'Calendar Date'[Date]
                >= _CurrentProdDate,
            USERELATIONSHIP (
                Contract[Contract End Date],
                'Calendar Date'[Date]
            )
        )
    )

return
    _ContractToBeEnded
 
Appreciate any help please.
 
Regards,
VVI
6 REPLIES 6
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

VVI
Frequent Visitor

Hi @lbendlin 

 

Thanks for the reminder.

Here's the data of source table.

 

CustomerAnnual Contract ValueActive DateContract Start DateContract End Date
Cust A                          40,00031-Dec-191-Mar-1828-Feb-23
Cust A                          50,00031-Dec-201-Mar-1828-Feb-23
Cust A                          55,00031-Dec-211-Mar-1828-Feb-23
Cust A                          60,00031-Dec-221-Mar-1828-Feb-23
Cust A                          75,00028-Feb-231-Mar-1828-Feb-23
Cust B                          75,00031-Dec-191-Jun-1931-May-22
Cust B                          75,00031-Dec-201-Jun-1931-May-22
Cust B                          50,00031-Dec-211-Jun-1931-May-22
Cust B                          50,00031-May-221-Jun-1931-May-22
Cust C                          10,00031-Dec-211-May-2130-Apr-23
Cust C                          15,00031-Dec-221-May-2130-Apr-23
Cust C                          15,00030-Apr-231-May-2130-Apr-23
Cust D                          25,00031-Dec-221-Sep-2231-Aug-24
Cust D                          50,00031-Dec-231-Sep-2231-Aug-24
Cust D                          50,00031-Aug-241-Sep-2231-Aug-24

 

And the result expected in table view

 

MonthValue of Contract Expected to be Ended
2023-0275000
2023-0415000
2024-0850000

What is the importance of Contract Start Date?  Is it part of the issue?

 

how are you amortizing the annual contract value over the months?  Or is that not important?

 

Is this what you are looking for? 

lbendlin_1-1675611006535.png

 

 

VVI
Frequent Visitor

Hi @lbendlin 

 

Contract Start Date is not the issue now, and there's no need to amortize contract over the year.

 

Is your visual using the period from Calendar Table?

VVI
Frequent Visitor

Hi @lbendlin 

 

As addition, I'd like to show the contract value for the year of current production year and moving forward. So, previous year, i.e. 2022 is not required.

So, that's why I'm adding a filter:

 

'Calendar Date'[Date]
                >= _CurrentProdDate
or
Contract[Contract End Date]
                >= _CurrentProdDate
 
But both doesn't work.
The later still shows 2022 value, which I don't need.


Please show the expected outcome based on the sample data you provided.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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