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

How to create custom based on the binary product of non-null cell values

I need to create a column that populates eby calculating the value of cells within a certain range with those that are not null as +1 and ones that are empty/null as 0.  In other words, if cells A1-A10 contained some kind of text, then the corresponding cell in the new column would equal 10.  If cells A1-A8 were not blank the corresponding value would be 8. If none contained text of any kind the value would equal zero and so on.

 

I realize the easiest way to get around this would probably just be to make a calculated column in excel and then add it that way but I'm also trying to understand the M syntax in this scenario for future reference as well.

 

Thanks in advance for any suggestions!

2 REPLIES 2
artemus
Employee
Employee

List.Count(List.Select(List.Transform(List.Range(Record.FieldNames(_), 1, 5), (name) => Record.Field(_, name)), each _ <> null))

where 1, 5 is the 0 based start and end index of your columns

Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

could you please post a example and the desired output?

 

Jimmy

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.

Top Solution Authors
Top Kudoed Authors