cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Condition BlankValue Compare Contains Value

Hi.

I want to create a Custom Column in Power Query where if column is null and the other column contains information (any data) it says FALSE.

And another condition if both columns have data it says YES.

 

In this particular case I don't want to specify the amount on the cell that contains data.

 

See below:

 

IDDEBITCREDITEXPECTED RETURN
1001null1FALSE
10022nullFALSE
1003null2FALSE
1004null2FALSE
100512TRUE 
100621TRUE
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Condition BlankValue Compare Contains Value

Hi @barbaracmv , 

You could try below M code to see whether it work or not.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMFTSUcorzckBUoZKsTpgMSMgxwgmDhUzRqgzgomZYBEzBRuEJGAGNQxoeiwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, DEBIT = _t, CREDIT = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"DEBIT", Int64.Type}, {"CREDIT", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"ID"}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Columns", {"ID"}, {{"Count", each Table.RowCount(_), type number}, {"all", each _, type table [ID=number, Attribute=text, Value=number]}}),
    Custom1 = Table.ReplaceValue( #"Grouped Rows",each [Count], each if [Count]>1 then "True" else "False", Replacer.ReplaceValue, {"Count"}),
    #"Expanded all" = Table.ExpandTableColumn(Custom1, "all", {"Attribute", "Value"}, {"Attribute", "Value"}),
    #"Pivoted Column" = Table.Pivot(#"Expanded all", List.Distinct(#"Expanded all"[Attribute]), "Attribute", "Value", List.Sum)
in
    #"Pivoted Column"

Best Regards,
Zoe Zhi

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

3 REPLIES 3
Highlighted
Super User IV
Super User IV

Re: Condition BlankValue Compare Contains Value

if [DEBIT] = null OR [CREDIT] = null then false else true

 

?


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




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

Proud to be a Super User!




Highlighted
Frequent Visitor

Re: Condition BlankValue Compare Contains Value

Hi Greg! Thanks for your response.

 

But in my scenario I won't have nulls values in the same row for both columns.

 

I want to put a condition that if COLUMN A contains data and COLUMN B contains data then TRUE. Else would be false because on either columns a null value is displayed.

 

Hope that is clear! but thanks anyway 🙂

Highlighted
Community Support
Community Support

Re: Condition BlankValue Compare Contains Value

Hi @barbaracmv , 

You could try below M code to see whether it work or not.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMFTSUcorzckBUoZKsTpgMSMgxwgmDhUzRqgzgomZYBEzBRuEJGAGNQxoeiwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, DEBIT = _t, CREDIT = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"DEBIT", Int64.Type}, {"CREDIT", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"ID"}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Columns", {"ID"}, {{"Count", each Table.RowCount(_), type number}, {"all", each _, type table [ID=number, Attribute=text, Value=number]}}),
    Custom1 = Table.ReplaceValue( #"Grouped Rows",each [Count], each if [Count]>1 then "True" else "False", Replacer.ReplaceValue, {"Count"}),
    #"Expanded all" = Table.ExpandTableColumn(Custom1, "all", {"Attribute", "Value"}, {"Attribute", "Value"}),
    #"Pivoted Column" = Table.Pivot(#"Expanded all", List.Distinct(#"Expanded all"[Attribute]), "Attribute", "Value", List.Sum)
in
    #"Pivoted Column"

Best Regards,
Zoe Zhi

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

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Super Users of the Quarter - Q2 2020

Super Users of the Quarter - Q2 2020

Who are our Super User Superstars? Who made it to the top of the leaderboards? Get the answers!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Community Summit Australia – Join Online!

Community Summit Australia – Join Online!

Be a part of the leading Microsoft Business Applications digital event, curated for the APAC community.

Top Solution Authors