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
BenGWeeks
Regular Visitor

AVERAGE of LEFT(column,1) ignoring blanks / IsNaN

Hello,

 

I have a Microsoft Forms survey as per below:

 

BenGWeeks_0-1611581614995.png

 

This is being stored into a SharePoint list that I amn retrieving via OData. The data looks like as follows:

 

BenGWeeks_1-1611581685181.png

 

I would like to create a average of these scores (ignoring the "I don't know" and "N/A" answers that are not numbers). I was thinking along the lines of create a new column with the following formula:

 

BenGWeeks_2-1611581798206.png

 

However, the columns that do not start with a number are presumably breaking it.

 

Any help much appreciated.

 

Regards,

 

Ben

 

 

 

2 ACCEPTED SOLUTIONS
PhilipTreacy
Super User
Super User

Hi @BenGWeeks 

Please download this sample PBIX file containing the following code and visual.

You can tidy this data up in Power Query to give you just numbers, so starting this with this sample data

scores-1.png

 

You end up with this

scores-2.png

 

This is the code that performs these transformations

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlHQVQguKcrPS8+pVEhML0pNVdJRMgYJ5uemlmcklsAFjZAFUzKLYeJYTIjVwWEwRYIgU7G6jHhBbKbGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Split Column by Delimiter", "Column2", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Column2.1", "Column2.2"}),
    #"Split Column by Delimiter2" = Table.SplitColumn(#"Split Column by Delimiter1", "Column3", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Column3.1", "Column3.2"}),
    #"Split Column by Delimiter3" = Table.SplitColumn(#"Split Column by Delimiter2", "Column4", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Column4.1", "Column4.2", "Column4.3", "Column4.4"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Split Column by Delimiter3",{"Column1.1", "Column2.1", "Column3.1", "Column4.1"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Other Columns",{{"Column1.1", Int64.Type}, {"Column2.1", Int64.Type}, {"Column3.1", Int64.Type}, {"Column4.1", Int64.Type}})
in
    #"Changed Type"

 

You can now create a Table Visual with these columns and choose Average as the aggregation

avgvals.png

avgxz.png

avgv.png

 



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!


View solution in original post

v-yangliu-msft
Community Support
Community Support

Hi  @BenGWeeks,

Here are the steps you can follow:

1. Create calculated column.

abc_column =
IF(ISERROR(LEFT('Table'[abc],1)+1),BLANK(),LEFT('Table'[abc],1))
asd_column =
IF(ISERROR(LEFT('Table'[asd],1)+1),BLANK(),LEFT('Table'[asd],1))
dfc_column = IF(ISERROR(LEFT('Table'[dfc],1)+1),BLANK(),LEFT('Table'[dfc],1))

2. Result:

v-yangliu-msft_0-1611709953823.jpeg

3. Place the three calculated columns in the visual table and select AVG

v-yangliu-msft_1-1611709953828.png

4. Result:

v-yangliu-msft_2-1611709953829.png

 

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @BenGWeeks,

Here are the steps you can follow:

1. Create calculated column.

abc_column =
IF(ISERROR(LEFT('Table'[abc],1)+1),BLANK(),LEFT('Table'[abc],1))
asd_column =
IF(ISERROR(LEFT('Table'[asd],1)+1),BLANK(),LEFT('Table'[asd],1))
dfc_column = IF(ISERROR(LEFT('Table'[dfc],1)+1),BLANK(),LEFT('Table'[dfc],1))

2. Result:

v-yangliu-msft_0-1611709953823.jpeg

3. Place the three calculated columns in the visual table and select AVG

v-yangliu-msft_1-1611709953828.png

4. Result:

v-yangliu-msft_2-1611709953829.png

 

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This was perfect thanks Liu 🙂

PhilipTreacy
Super User
Super User

Hi @BenGWeeks 

Please download this sample PBIX file containing the following code and visual.

You can tidy this data up in Power Query to give you just numbers, so starting this with this sample data

scores-1.png

 

You end up with this

scores-2.png

 

This is the code that performs these transformations

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlHQVQguKcrPS8+pVEhML0pNVdJRMgYJ5uemlmcklsAFjZAFUzKLYeJYTIjVwWEwRYIgU7G6jHhBbKbGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Split Column by Delimiter", "Column2", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Column2.1", "Column2.2"}),
    #"Split Column by Delimiter2" = Table.SplitColumn(#"Split Column by Delimiter1", "Column3", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Column3.1", "Column3.2"}),
    #"Split Column by Delimiter3" = Table.SplitColumn(#"Split Column by Delimiter2", "Column4", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Column4.1", "Column4.2", "Column4.3", "Column4.4"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Split Column by Delimiter3",{"Column1.1", "Column2.1", "Column3.1", "Column4.1"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Other Columns",{{"Column1.1", Int64.Type}, {"Column2.1", Int64.Type}, {"Column3.1", Int64.Type}, {"Column4.1", Int64.Type}})
in
    #"Changed Type"

 

You can now create a Table Visual with these columns and choose Average as the aggregation

avgvals.png

avgxz.png

avgv.png

 



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!


iXpert_info
Helper II
Helper II

Hey @BenGWeeks 

One Interesting solution is you can replace NA and I don't Know as "0-N/A" and "0-I don't Know"

That will consider both of your those answers as 0 and it wont disturb your above measure.

Did I answer your question? Please mark this as solution

Best Regards
Jay Patel
iXpert Analytics

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.