The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Helo developers,
I would like create new column 'Result' for have the same output like my exemple.
Count the numbers of columns are not null.
Exemple :
Column 1 | Column 2 | Column 3 | RESULT |
2 | null | null | 1 |
null | 6 | 7 | 2 |
null | null | null | 0 |
4 | 7 | 10 | 3 |
Thanks for your returns !
Solved! Go to Solution.
Hey @Mat40220 ,
You can use the List.NonNullCount how the @AnkitKukreja said.
The code is
#"Added Custom" = Table.AddColumn(YOUR_PREVIEW_STEP, "RESULT", each List.NonNullCount({[Column1],[Column2],[Column3]}))
Best Regards,
Marcel
Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI
Is there any reason why this would return an answer of 1 when all columns counted are null ?
example: (foreman.1.2 is column 8 when referencing the formula below):
results:
formula:
"Count_Foreman", each List.NonNullCount(List.Range(Record.FieldValues(_),8,4)))
This returns the correct number for all "NonNull" counts, but when all four columns are null, it returns "1" every time.
Hi @Mat40220
You can add a custom column in the Power Query editor and use the below formula.
List.NonNullCount({[Column 1],[Column 2],[Column 3]})
Hey @Mat40220 ,
Without think too much, I believe you can solve using this measure:
Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI
Thank Marcel,
But i want write the solution in power query (with M language)
Do you have an idea ?
Hey @Mat40220 ,
You can use the List.NonNullCount how the @AnkitKukreja said.
The code is
#"Added Custom" = Table.AddColumn(YOUR_PREVIEW_STEP, "RESULT", each List.NonNullCount({[Column1],[Column2],[Column3]}))
Best Regards,
Marcel
Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
80 | |
74 | |
52 | |
50 |
User | Count |
---|---|
132 | |
124 | |
78 | |
64 | |
61 |