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
mohittimpus
Helper V
Helper V

Get all Company name based on Industry Name

Hello All,

 

I have 2 table:

1) Company

2) Employee

 

I have a filter of company name in page1 tab. I want to fatch the All company name based on Industry name.

 

one filter is there of company name which is taking by company table.

 

industry name i am facthing with respect company name with below measure:

 

Get Industry by company =

var val = SELECTEDVALUE(Companies[company name])
var industry = IF(val<>BLANK(), VALUES(CreditorWatch[ANZSIC Industry]))
return industry

 

here I am getting Industry name using above measure. 

 

Now, in below image one Industry has 2 company name.

 

 
 

 

Screenshot_1.jpg

 

there are 2 company name in same industry "K_Finance and insurance services".

 

I want this 2 company name for industry "K_Finance and insurance services". in a measure.

 

I used below measure:

 

var val = SELECTEDVALUE(Companies[company name])
var industry = IF(val<>BLANK(), VALUES(employee[Industry]))
return industry

 

I got industry name by above measure.

 

after that i used below measure to get company name but i am getting single company name, but it must take 2 company name for industry "K_Finance and insurance services". 

 

All Company Name = IF([Get Industry by company]<>BLANK(), VALUES(employee[Name]))
 
above measure is showing only 1 company. 
 
below file is attached Excel and .pbix file. 
 
power bi file:
 
 
Excel sheet image
 
Screenshot_2.jpg
 

 

 

 

 

 

 

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @mohittimpus ,

A measure is not able to express multiple values at the same time. It is usually an aggregate value. So in this case, you can use CONCATENATEX function to combine all the values into one single string value and then display it in the visual. Try the measure below, here I use “; ” as the delimiter between values.

 

All Company Name =
VAR __industry = SELECTEDVALUE ( employee[Industry] )
VAR __table = FILTER ( ALL ( employee ), employee[Industry] = __industry )
VAR __table2 = SUMMARIZE ( __table, employee[Company Name] )
RETURN
    CONCATENATEX ( __table2, employee[Company Name], "; " )

 

v-jingzhang_0-1600683538158.png

Moreover, if you want to display multiple company names in multiple rows of a table visual, here is another way you can take which needs a few steps to follow:

1. Create a Company List table

 

CompanyList = VALUES(Companies[company name])

 

2. Create a measure

 

Measure =
VAR __industry = SELECTEDVALUE ( employee[Industry] )
VAR __table = FILTER ( ALL ( employee ), employee[Industry] = __industry )
VAR __table2 = SUMMARIZE ( __table, employee[Company Name] )
RETURN
    IF ( MAX ( CompanyList[Company Name] ) IN __table2, 1, 0 )

3. Put CompanyList[company name] column into the table visual and add above measure to the table’s filter.

 

v-jingzhang_1-1600683538165.png

 

Best Regards,

Community Support Team _ Jing Zhang

If this post helps, please consider Accept it as the solution to help other members find it.

AllisonKennedy
Super User
Super User

To get two company names in single measure, you need to use CONCATENATEX to combine multiple rows into 1 value.
You'll also have to make sure you put it in the right visual, because if you put it by company name, you'll only see one company name.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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.