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.
Hello,
I would like to create a dax formula (or find another way) to create a measure that sums the number columns that have at lease one non-null value in it. I have a number of features for a program where each column is a feature. The rows for each column hold a value (image file, date, true/false). Now I want to summarize these columns by the Total amount of columns that contain at least one non-null value.
Thanks! :))))
Solved! Go to Solution.
Number of columns with not null values =
var _column1 = IF(ISBLANK(CALCULATE(DISTINCTCOUNT('SampleData'[Column1]),NOT('SampleData'[Column1] in {"NULL","null"}))),0,1)
var _column2 = IF(ISBLANK(CALCULATE(DISTINCTCOUNT('SampleData'[Column2]),NOT('SampleData'[Column2] in {"NULL","null"}))),0,1)
var _column3 = IF(ISBLANK(CALCULATE(DISTINCTCOUNT('SampleData'[Column3]),NOT('SampleData'[Column3] in {"NULL","null"}))),0,1)
return _column1 + _column2 + _column3
Due to fact that your request do not have any expected results I've assumed that you want to calculate amount of column that has at least 1 row with different value than NULL or null, so the result will be 2.
Am I correct?
Proud to be a Super User!
Hi @jsmith435 ,
Please try below steps:
1. below is my test table
Table:
2. create a measure with below dax formula
Measure =
VAR _a =
CONCATENATEX ( 'Table', [Column1], "," )
VAR _b =
CONCATENATEX ( 'Table', [Column2], "," )
VAR _c =
CONCATENATEX ( 'Table', [Column3], "," )
VAR _val1 =
IF ( CONTAINSSTRING ( _a, "NULL" ), 1, 0 )
VAR _val2 =
IF ( CONTAINSSTRING ( _b, "NULL" ), 1, 0 )
VAR _val3 =
IF ( CONTAINSSTRING ( _c, "NULL" ), 1, 0 )
RETURN
_val1 + _val2 + _val3
3. add a table visual with measure
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Share data in a format the can be pasted in an MS Excel file and show the expected result.
Hi @jsmith435 ,
Please try below steps:
1. below is my test table
Table:
2. create a measure with below dax formula
Measure =
VAR _a =
CONCATENATEX ( 'Table', [Column1], "," )
VAR _b =
CONCATENATEX ( 'Table', [Column2], "," )
VAR _c =
CONCATENATEX ( 'Table', [Column3], "," )
VAR _val1 =
IF ( CONTAINSSTRING ( _a, "NULL" ), 1, 0 )
VAR _val2 =
IF ( CONTAINSSTRING ( _b, "NULL" ), 1, 0 )
VAR _val3 =
IF ( CONTAINSSTRING ( _c, "NULL" ), 1, 0 )
RETURN
_val1 + _val2 + _val3
3. add a table visual with measure
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Number of columns with not null values =
var _column1 = IF(ISBLANK(CALCULATE(DISTINCTCOUNT('SampleData'[Column1]),NOT('SampleData'[Column1] in {"NULL","null"}))),0,1)
var _column2 = IF(ISBLANK(CALCULATE(DISTINCTCOUNT('SampleData'[Column2]),NOT('SampleData'[Column2] in {"NULL","null"}))),0,1)
var _column3 = IF(ISBLANK(CALCULATE(DISTINCTCOUNT('SampleData'[Column3]),NOT('SampleData'[Column3] in {"NULL","null"}))),0,1)
return _column1 + _column2 + _column3
Due to fact that your request do not have any expected results I've assumed that you want to calculate amount of column that has at least 1 row with different value than NULL or null, so the result will be 2.
Am I correct?
Proud to be a Super User!
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 |
---|---|
107 | |
97 | |
75 | |
65 | |
53 |
User | Count |
---|---|
144 | |
103 | |
98 | |
85 | |
64 |