Forum Discussion
Userealtionship DAX
HI Experts
I have teh following DAX measure using a switch function, i want to add userelationship to this measure... not sure if it is possible.
B1 Actuals =
VAR SummaryItem = TRIM(SELECTEDVALUE( 'Templates'[Summary 4] ))
Return
SWITCH(TRUE(),
SummaryItem = "U.S.", FORMAT(CALCULATE([Total Revenue], FILTER(Management,Management[Level7] ="TOTAL U.S.")),"$#,##0.0;($#,##0.0)"),
SummaryItem = "Canada", FORMAT(CALCULATE([Total Revenue], FILTER(Management,Management[Level6]= "Canada")),"$#,##0.0;($#,##0.0)"),
BLANK(),USERELATIONSHIP(Management[Level4],Templates[Summary 4]))5 Replies
- AnonymousNot applicable
Thanks AIB
I am trying to filter the data in the table based on the selections in a filter, i am using a template uploaded from excel in Power BI, currently the template has been added to the data model as a discount table.
So by creating a inactive relationship between template table and the management level table i should be able to filter the data in the table????
- AlB
Community Champion
Anonymous
First of all, I do no think the last option with Blank is ever going to execute. You are doing SWITCH(TRUE() and blank is never equal to TRUE.
Regarding USERELATIONSHIP, you use it to temporarily activate an existing inactive relationship.
- v-yulgu-msft
Microsoft Employee
Hi Anonymous,
There is no any relationship betweent 'Templates' table and 'Management' table, right? In such a scenario, there is no need to use USERELATIONSHIP function in the measure. Please see below:
B1 Actuals = VAR SummaryItem = TRIM(SELECTEDVALUE( 'Templates'[Summary 4] )) Return SWITCH(TRUE(), SummaryItem = "U.S.", FORMAT(CALCULATE([Total Revenue], FILTER(Management,Management[Level7] ="TOTAL U.S.")),"$#,##0.0;($#,##0.0)"), SummaryItem = "Canada", FORMAT(CALCULATE([Total Revenue], FILTER(Management,Management[Level6]= "Canada")),"$#,##0.0;($#,##0.0)"), BLANK())Best regards,
Yuliana Gu