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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply

averagea calculation

Hi

Issue 1: I have 5 rows with data as "1" but in the visual only one "1" is displayed.

Issue 2: Avga result is 0.00

 

 

RamaKrishna8989_0-1668648350623.png

 

 

 

RamaKrishna8989_0-1668648674068.png

 

 

@Syndicate_Admin

@aserpiva64

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi RamaKrishna8989

 

Issue 1:In the visual only one "1" is displayed.

The table automatically filters duplicate values, so you need to put another column of non-duplicate values in the table, and “1” will be displayed

 

vxinruzhumsft_0-1668754005398.png

 

Issue 2: Enter boolean values such it calculates as "0" and "1"

You can enter the power query editor and input the following codes to the “Advance Editor”

 

let

    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSAeJYHQjLCM4yhrNM4CxTMMs/LxXIDinPB/NCgkJdgVw3R59gV6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"col 1" = _t, #"col 2" = _t]),

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"col 1", type text}, {"col 2", type text}}),

    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Value.Is(Value.FromText([col 1]),type number) then 1 else 0),

    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Int64.Type}}),

    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Custom", "Boolean"}}),

    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"col 1", "Boolean", "col 2"})

in

    #"Reordered Columns"

 

It will display a new table like the following picture, then apply the data to the desktop.

vxinruzhumsft_1-1668754005403.png

 

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Xinru Zhu

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

6 REPLIES 6
Anonymous
Not applicable

Hi RamaKrishna8989

 

Issue 1:In the visual only one "1" is displayed.

The table automatically filters duplicate values, so you need to put another column of non-duplicate values in the table, and “1” will be displayed

 

vxinruzhumsft_0-1668754005398.png

 

Issue 2: Enter boolean values such it calculates as "0" and "1"

You can enter the power query editor and input the following codes to the “Advance Editor”

 

let

    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSAeJYHQjLCM4yhrNM4CxTMMs/LxXIDinPB/NCgkJdgVw3R59gV6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"col 1" = _t, #"col 2" = _t]),

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"col 1", type text}, {"col 2", type text}}),

    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Value.Is(Value.FromText([col 1]),type number) then 1 else 0),

    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Int64.Type}}),

    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Custom", "Boolean"}}),

    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"col 1", "Boolean", "col 2"})

in

    #"Reordered Columns"

 

It will display a new table like the following picture, then apply the data to the desktop.

vxinruzhumsft_1-1668754005403.png

 

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Xinru Zhu

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

danextian
Super User
Super User

Hi @RamaKrishna8989 ,

 

What is your logic in getting the average a column that is of type text? Column 2 has both numbers and letters so it is a text.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian.

 

AverageA handles Text and Non-numerics. Hence i had to select Text datatype. If that is incorrect which datatype should i select?

RamaKrishna8989_0-1668651027796.png

 

See here: https://dax.guide/averagea/

 

It is useless to use this function in DAX with a string column because the result is always 0, resulting in a different result compared to the corresponding AVERAGEA function in Excel. In order to calculate the average of the numbers included in a column with a string data type, use AVERAGEX instead of AVERAGEA converting the column into a number using VALUE

Try that suggestion instead:

 

AVERAGEX ( AAASheet1, VALUE ( AAASheet1[Col 1] ) )

 

Thanks Alexis. but i am trying to achieve the below output.

 

RamaKrishna8989_0-1668733477686.png

I want Text value as Zero and Boolean True as One and return the average. 

My doubts here are:

1) In Col1, why is it considering only one "1" when i have value "1" in five rows

2) How should i enter boolean values such it calculates as "0" and "1"

 

@danextian @Syndicate_Admin 

 

 

Hi @RamaKrishna8989 ,

 

You can  just create a calculated column to convert the strings in column to your desired number equivalent use that column instead to get the average. 

Col3 =
VAR _string = 'Table'[Col2]
RETURN
    IFERROR ( VALUE ( 'Table'[Col2] ), ( IF ( _string = "TRUE", 1, 0 ) ) )




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.