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
SJE_HT
Regular Visitor

How to add content to cells programmatically

Hello,

 

I'm sorry if this is a rather obvious question, but I am trying to learn how to add cell content programmatically. The particular goal I'm trying to achieve is to look through a table and add content to a cell if it fulfills certain criteria.  In my example, I have a list of companies and contacts who are attending an event.  Some companies have no staff members attending the event at all, but other companies have at least one staff member who is attending the event.  

 

I'd like to be able to see all the companies who have no staff members attending at all and not also include staff members who are from a company where someone else is attending. To do this, I'd need to look through the table and find every contact who is attending and for each staff member that is attending,  find their company and mark all contacts from that company as attending.  Alternatively, for each staff member that is attending, remove all instances of their company within the table.  This is a fairly simple programming task, but I'm new to Power Bi and thought I would ask if there was an easy solution to this that I'm missing.  

 

I've posted a screenshot of some arbitrary data which shows some people attending and others in the same company not attending. I'd like to apply the 'YES' to all those who are at the same company. The end goal would be to then have a clean list of companies who have no staff members attending at all.

 

I'd appreciate any ideas! Thanks.

 

powerbi_question.JPG 

2 REPLIES 2
MarkS
Resolver IV
Resolver IV

Hello,

You should be able to do this with PowerQuery.

  1. Duplicate your original query
  2. Remove all columns except "Company" and "Attending"
  3. Filter "Attending" Column for "YES"
  4. On Company Name Column remove duplicates

This will leave you with a table containing the company names that have an employee attending and you can then merge this table back with the original on the company name column.

 

Depending on the join type selected you could get back only those companies that are not on the list of companies that have an employee attending (Using one of the ANTI join types)

JoinTypes(PQ).PNG

Here is a DAX solution which will give you a list of Companies who had no one attending at all

 

Table 2 = 
VAR T1 =  SELECTCOLUMNS(FILTER('Sheet1','Sheet1'[Attending]="YES"),"Company Name",[Company Name])
VAR T2 = SUMMARIZE('Sheet1',Sheet1[Company Name])
RETURN EXCEPT(T2,T1)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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.