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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
linoybar
Frequent Visitor

Comparative Analysis implementation in Power BI

Hi,

 

I'm trying to create a measure that will use an inactive relationship in order to count number of incidents from MyFactTable that will be influenced by user selecting specific values from units filter which is a column in that inactive table named UnitsTable1.

What I have now is that it works only for totals but when I make a selection in a filter I get blank.

 

The active table is called UnitsTable.

 

Here is my dax:

 

Measure = CALCULATE(counta(MyFactTable[IncidentKey],

                   USERRELATIONSHIP(MyFactTable[IncidentKey], MyMappingTable[IncidentKey],

                   USERRELATIONSHIP(MyMappingTable[UnitKey], UnitsTable1[UnitKey])

)

 

 

At the end the purpose is to show in a single chart comparison between number of incidents of UnitA vs number of incidents of UnitB+UnitC, for example.

So I've uploaded the UnitsTable twice into my Tabular model. They have UnitColumn which I put as filters. 

So then the user will choose UnitA from UnitColumn from UnitsTable, and Unit B and Unit C from UnitColumn from UnitsTable1, 

and then the chart needs to show 2 lines - one for number of incidents for UnitA, and second for number of incidents for UnitB+C.

 

Please help 🙂

 

Thanx!

P.S. To clarify my initial issue, here is the best explanation of what I'm trying to achieve:
https://community.powerbi.com/t5/Desktop/Alternate-states-functionality/td-p/238984

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @linoybar,

 

AFAIK, for calculate function, it use 'and' logic to link each filters.

So if you put multiple filters in it, it will try to find out records who achieve each conditions at same time. 

 

I think this is the reason of blank calculation result.

 

Maybe you can try to split your formula as two calculation and summary them get total value:

Measure =
CALCULATE (
    COUNTA ( MyFactTable[IncidentKey] ),
    USERELATIONSHIP ( MyFactTable[IncidentKey], MyMappingTable[IncidentKey] )
)
    + CALCULATE (
        COUNTA ( MyFactTable[IncidentKey] ),
        USERELATIONSHIP ( MyFactTable[IncidentKey], UnitsTable1[UnitKey] )
    )

 

Reference link:

Order of Evaluation in CALCULATE Parameters

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft,

 

Thanks for your reply.

In my model MyFactTable is connected to MyMappingTable, and MyMappingTable is connected to UnitsTable1.

As you can see, there is no straight connection between MyFactTable  and MyMappingTable.

Only the connection between MyMappingTable and Unitstable1 is inactive - this is the one I'm trying to activate using USERRELATIONSHIP.

So maybe the part of

USERELATIONSHIP ( MyFactTable[IncidentKey], MyMappingTable[IncidentKey]

is unnecessary since it's always activated anyway.

I tried either ways, but nothing worked...

HI @linoybar,

 

Nope, I think it is impossible.

 

USERELATIONSHIP seems only works on two table who contains direct relationship, I don't think you can nested multiple functions to enable relationship for other tables.

 

Marco also mentioned for USERELATIONSHIP function , you can take a look at below blog to know more about it.

USERELATIONSHIP in Calculated Columns


Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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