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.
Hi all,
First post!
In Power BI I'm trying to 'Add a column' that is the average of 3 columns, one of the columns may have a 'null' value in it, please see the data below:
So for each row I need to find the average of '47254', '121844' and '139820', unfortunately data is not always present and will have a 'null' as shown and this needs to be excluded.
Thank you in advance
Solved! Go to Solution.
I agree that unpivotting is almost always the way to go. However, if you need to keep your 3 columns pivotted, this approach will get you the average and exclude nulls
Custom Column M code - List.Average(List.RemoveNulls({[Column2],[Column3],[Column4]}))
Putting your 3 columns as a list inside curly brackets makes it a list, and then you can take advantage of the set of list functions in M.
If this works for you, please mark it as solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
I agree that unpivotting is almost always the way to go. However, if you need to keep your 3 columns pivotted, this approach will get you the average and exclude nulls
Custom Column M code - List.Average(List.RemoveNulls({[Column2],[Column3],[Column4]}))
Putting your 3 columns as a list inside curly brackets makes it a list, and then you can take advantage of the set of list functions in M.
If this works for you, please mark it as solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thank you this is perfect, as part of the next step I unpivot the columns but wanted a site average before I did that and appended all my sites together
@NATO-OZ - Welcome to the community! You might think about unpivoting those columns in Power Query and then you could just use the default average aggregation or AVERAGE DAX function. If you cannot unpivot the columns, you can use my MC Aggregation DAX Quick Measure here: https://community.powerbi.com/t5/Quick-Measures-Gallery/Multi-Column-Aggregations-MC-Aggregations/m-...
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
82 | |
70 | |
60 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |