Forum Discussion

D_PBI's avatar
D_PBI
Post Partisan
1 year ago
Solved

USERELATIONSHIP not working - why?

Hi. My below DAX measure is not returning the correct numbers and I believe it is due to the USERELATIONSHIP not working as expected. There are two tables in question here: dimDate and agreem...
  • mark_endicott's avatar
    mark_endicott
    1 year ago

    D_PBI - your measure for the Consultancy Agreements graph is incorrect when you have the dimDate[Date] <> agreement[Execution Date] active, because this relationship is still filtering the data even though you have used USERELATIONSHIP to activate the other inactive relationship. This is why I suggest de-activating all date table relationships. 

     

    Once you have done this, you need to reconfigure how your filters work, in order for the correct context to be used in your cumulative totals. I would suggest chaining your measures together. This means splitting your logic out into two measures. See below:

     

    Measure 1 = CALCULATE( DISTINCTCOUNT ( item ), USERELATIONSHIP( dimDate[Date], agreement[Execution Date] ))
    
    Measure 2 = CALCULATE ( [Measure 1], FILTER ( ALLSELECTED ( Date logic........

     

    This ensures the filter context for date is already applied when you ask the 2nd measure to route through your dates. 

     

    I would also suggest you mark your dimDate as a date table, this helps Power BI understand where time intelligence is being used. 

     

    If you still can't get this to work and need me to help any more, you will need to supply some anonymised test data in the exact structure of your model so I can do some testing of my work, and send you back an example file that shows you how this works.

     

    If I answered your question please mark my post as the solution, it helps others with the same challenge find the answer!

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi D_PBI,

     

    Thanks for your update. I completely understand the constraints around creating a dummy file from scratch. However, to properly troubleshoot the issue with USERELATIONSHIP, we really need a sample .pbix file ideally with the same data model structure or a simplified version that still reproduces the issue.

    Even just a file with mock data that replicates the relationships and expected behavior would be incredibly helpful. This will allow us to test and provide a more targeted solution.

    Please do share it whenever you're able. We're happy to help further once we have something concrete to work with.

     

    Warm regards,
    Prasanna Kumar