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 have tried to look in the community for the answer. Few issues with the exact error can be found. However, I cannot fix mine. Appreciate that any one can look at my formula.
Positive Recovery = If (Category = "Income", - value, value)
The formula above is too convert the credit sign of income (in accounting) to positive while keeping the expenses side as (debit / positive).
It has been worked until I refresh the data. It is wired. Thanks!
Solved! Go to Solution.
Hi @stella_moon ,
Based on the error message, it is caused by the different data types in column. I think you are trying to use both number value and text value (the value with sign) in one calculate column. So power bi can't auto analysis data type of it.
Maybe you could try like this:
Positive Recovery =
IF ( 'Table'[Category] = "Income", "-" & 'Table'[value], 'Table'[value] )
Or you could try the function of FORMAT to convert values to text value.
Pre-Defined Numeric Formats for the FORMAT function
If you want to change all the values to number, you need to split the sign in Power Query firstly.
= Table.AddColumn(#"Changed Type1", "Custom", each if [value.1] = null then [value.2] else [value.1])
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8sxLzs9NVdJRMjQwUIrViVZyBLK1DA1MwRwnkISRMZjtrADimAFVxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Category = _t, value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Category", type text}, {"value", type text}}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "value", Splitter.SplitTextByDelimiter("*", QuoteStyle.Csv), {"value.1", "value.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"value.1", Int64.Type}, {"value.2", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each if [value.1] = null then [value.2] else [value.1]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"value.1", "value.2"})
in
#"Removed Columns"
For more details, please see the attachment.
Hi @stella_moon ,
Based on the error message, it is caused by the different data types in column. I think you are trying to use both number value and text value (the value with sign) in one calculate column. So power bi can't auto analysis data type of it.
Maybe you could try like this:
Positive Recovery =
IF ( 'Table'[Category] = "Income", "-" & 'Table'[value], 'Table'[value] )
Or you could try the function of FORMAT to convert values to text value.
Pre-Defined Numeric Formats for the FORMAT function
If you want to change all the values to number, you need to split the sign in Power Query firstly.
= Table.AddColumn(#"Changed Type1", "Custom", each if [value.1] = null then [value.2] else [value.1])
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8sxLzs9NVdJRMjQwUIrViVZyBLK1DA1MwRwnkISRMZjtrADimAFVxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Category = _t, value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Category", type text}, {"value", type text}}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "value", Splitter.SplitTextByDelimiter("*", QuoteStyle.Csv), {"value.1", "value.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"value.1", Int64.Type}, {"value.2", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each if [value.1] = null then [value.2] else [value.1]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"value.1", "value.2"})
in
#"Removed Columns"
For more details, please see the attachment.
@stella_moon Try like
Positive Recovery = If ([Category] = "Income", -1*[value],[value])
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 | |
100 | |
80 | |
63 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |