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
Anonymous
Not applicable

Return multiple rows in a switch statement

So I have a app table that looks like this 

 

App NameIndexDataset
Facebook1fb
Twitter2tw
Gmail 3gm 

 

then I have three datasets 

users 

user name emailaddresszipemp id 
bob bob@gmailbob st. NYC402031243
stevesteve@gmailsteve st. NYC594200230
     

twitter security 

user namesecurity pageaccess date 
bob homepage1/1/1200
bobprofile

1/2/1200

 

bobFAQ1/2/1200

 

facebook security 

user namesecurity page

date

bobprofile1/2/1200
bobFAQ1/2/1200 

 

I then have a table visual which has the app name as the first column. I am trying to create switch statement of some sort to return the second column which is security page. The desired output looks like when I filter on bob: 

namesecurity
Facebook

Homepage

FacebookFAQ
TwitterHomepage
Twitter Profile 
GmailNo Security 

 

I have built the following to just test the first table... however it is only returning the max selection. My measure looks like 


SECURITY TEST =
IF(HASONEVALUE('App Table'[AppName]),
SWITCH(TRUE(),
'App Table'[Appname] = "Facebook", CALCULATE(IF(MAX('Facebook'[BaseUserName]) = [selectedID], max('Facebook'[Security]) ,0),FILTER('Facebook', 'FacebookID = [selectedID] ))))

 

BUT ^ this returns only one value from the Facebook security column and not every value. Please help! I cannot create a column in my model on the transactional data. 

2 REPLIES 2
v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

I'm not very clear about the logic and your expected output according to your data sample and description.

Could you please provide me with more details about your problem or share me with your pbix file from your Onedrive for Business after removing sensitive data?


Best Regards,
Eyelyn Qin

lbendlin
Super User
Super User

Familiarize yourself with CONCATENATEX().

 

DAX measures and columns can always only return a single value.  Unless you cheat.

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.