Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to Compute data in Percentage if there's a value in a column

Hello,

 

I have data in an excel file wherein the Overall Percentage should be 100%.

I want to compute that if for example, the Column F is NO, then the Overall Percentage should be multiplied by 0.5, but if YES then just 0.

Also, if there is a value in Column G(Name), then another multiply the Overall Percentage by 0.15. 

For every input in Column H-I, if it has any value, then it should be multiplied by 0.075 from the Overall Percentage also.

 

How to put the formula in Powerbi? I need to put it in a bar graph in PowerBI 

 

This is the formula if it's in excel

 

=(1-((IF(F2="NO",0.5,0))+(COUNTA(G2)*0.15)+(COUNTA(H2,I2)*0.075)*0.05)))/1

 

 

  • Hi, Anonymous ;

    You could try to create a custom column.

    =1-(if [found]="NO" then 0.5  else 0)-(List.NonNullCount({[Name]})*0.15)-(List.NonNullCount({[age],[Address]})*0.075*0.05)

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WqijNLVDSUTI0MjQ2NDIGsopSS4AIyDDVN9U3MjAyAjLLU1OzFQyBjMjUYiAJVg8k8kpzciBcMyM9UwNVpVidaKWSjEywiabGJsamIANLUmHmGeE2D8U0c5BRsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Code = _t, Number = _t, ID = _t, #"date processed" = _t, #"audit week" = _t, found = _t, Name = _t, age = _t, Address = _t, Info = _t, #"overall " = _t]),
        #"Replaced Value" = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"Name", "age", "Address", "Info"}),
        #"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"Code", type text}, {"Number", Int64.Type}, {"ID", type text}, {"date processed", type date}, {"audit week", type text}, {"found", type text}, {"Name", type text}, {"age", Int64.Type}, {"Address", Int64.Type}, {"Info", type text}, {"overall ", Percentage.Type}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each 1-(if [found]="NO" then 0.5  else 0)-(List.NonNullCount({[Name]})*0.15)-(List.NonNullCount({[age],[Address]})*0.075*0.05))
    in
        #"Added Custom"

    The final output is shown below:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

1 Reply

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous ;

    You could try to create a custom column.

    =1-(if [found]="NO" then 0.5  else 0)-(List.NonNullCount({[Name]})*0.15)-(List.NonNullCount({[age],[Address]})*0.075*0.05)

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WqijNLVDSUTI0MjQ2NDIGsopSS4AIyDDVN9U3MjAyAjLLU1OzFQyBjMjUYiAJVg8k8kpzciBcMyM9UwNVpVidaKWSjEywiabGJsamIANLUmHmGeE2D8U0c5BRsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Code = _t, Number = _t, ID = _t, #"date processed" = _t, #"audit week" = _t, found = _t, Name = _t, age = _t, Address = _t, Info = _t, #"overall " = _t]),
        #"Replaced Value" = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"Name", "age", "Address", "Info"}),
        #"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"Code", type text}, {"Number", Int64.Type}, {"ID", type text}, {"date processed", type date}, {"audit week", type text}, {"found", type text}, {"Name", type text}, {"age", Int64.Type}, {"Address", Int64.Type}, {"Info", type text}, {"overall ", Percentage.Type}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each 1-(if [found]="NO" then 0.5  else 0)-(List.NonNullCount({[Name]})*0.15)-(List.NonNullCount({[age],[Address]})*0.075*0.05))
    in
        #"Added Custom"

    The final output is shown below:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.