Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Count values from multiple fields

Dear Friends,

I want to calculate counts of values available in multiple fields like below -

for User A , Value is showing only in Acre1 field so count will be 1 and for User B, values are showing in 3 field

 
 
UserAcre1Acre2Acre3Acre4Acre5Count
A3    1
B201  3
C116225
D0    1
E76   2
F685  3
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you so much @PhilipTreacy for quick help . It works for me. 🙂

View solution in original post

3 REPLIES 3
PhilipTreacy
Super User
Super User

You're welcome @Anonymous 

You're supposed to mark the actual answer as the solution, not your own reply 🙂

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Thank you so much @PhilipTreacy for quick help . It works for me. 🙂

PhilipTreacy
Super User
Super User

Hi @Anonymous 

You can add a Custom Column in the Power Query editor like this

 

= Table.AddColumn(#"PreviousStepName", "Addition", each List.NonNullCount({[Acre1], [Acre2], [Acre3], [Acre4], [Acre5]}), Int64.Type)

 

non-null-count.png

 

Here's a full sample query, copy/paste this into a blank query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIGYgSK1YlWcgIyjIDYAIgNkcSdoXwQNoOqMQLLuEBVo5rjCmSYQ9UiCbtBhSyA2BQmHgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [User = _t, Acre1 = _t, Acre2 = _t, Acre3 = _t, Acre4 = _t, Acre5 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"User", type text}, {"Acre1", Int64.Type}, {"Acre2", Int64.Type}, {"Acre3", Int64.Type}, {"Acre4", Int64.Type}, {"Acre5", Int64.Type}}),
    #"Inserted Sum" = Table.AddColumn(#"Changed Type", "Addition", each List.NonNullCount({[Acre1], [Acre2], [Acre3], [Acre4], [Acre5]}), Int64.Type)
in
    #"Inserted Sum"

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.