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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
olegkazanskyi
Helper II
Helper II

DAX for USERRELATIONSHIP with 2 DIM tables and waterfall structure

Hello,

I have this schema with 2 inactive relationships and 1 active.

olegkazanskyi_1-1681761421331.png

 

 

This is a small part of a more complex model as an example for simplicity of explanation of the issue I am trying to solve.

 

The PBIX is also attached.

Link with the PBIX 

 

The Activity table can have blanks for the workspace ID or for the Report ID, depending on the activities.

I want to get a matrix with workspaces and reports combined, but I can't find a way to make it work.
No Report values show up under the workspace hierarchy.

olegkazanskyi_0-1681764721624.png

 

 

Here is my formula.

Count_Activities =
SWITCH (
    TRUE (),
     ISFILTERED ( report ) && ISFILTERED ( workspaces ),
        CALCULATE (
            COUNTROWS ( Activities ),
            USERELATIONSHIP ( report[id], Activities[Report ID] )
        ),
    ISFILTERED ( workspaces ),
        CALCULATE (
            COUNTROWS ( Activities ),
            USERELATIONSHIP ( workspaces[id], Activities[Workspace ID] )
        )
)

 

I can make it work for reports and workspaces on different visuals, but not when they are together.

2 REPLIES 2
amitchandak
Super User
Super User

@olegkazanskyi , you should merge report and workspace tables into one dimension and use that to join and filter Activities

 

You can use power query merge

 https://radacad.com/append-vs-merge-in-power-bi-and-power-query

@amitchandak , 
I may need a little more explanation if I may ask.
When I merge the two tables, as a result, I get many-to-many relations between  workspace_ID as there are duplicates in the new table now.
I can't make a relation solely by the report_id because of the Activity table structure.  A single activity can be related to the report or relevant only to the workspace.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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