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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
subirch
Frequent Visitor

Conditional Column Based on Three Criteria

Hi,

 

I and trying to calculate the "Tag" column based on two criteria for each customer. If Product is "Pd A" and sales is >=1,000,000 then "Yes" for each rows wherever same customer id is appearing else "No". The data set is large. I need the solution in PowerQueary not DAX.

 

Customer IDProductSalesTag
444444Pd A       1,000,000Yes
444444Pd B             76,000Yes
444444Pd C               5,600Yes
444444Pd E               4,000Yes
777777Pd A       2,000,000Yes
777777Pd B             54,398Yes
777777Pd C             40,000Yes
777777Pd E               2,000Yes
999999Pd A           100,000No
999999Pd B       2,000,000No
999999Pd C             50,000No
999999Pd E           453,666No

 

 

3 REPLIES 3
AlienSx
Super User
Super User

hi @subirch 

let
    data = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddAxDoAgDIXhq5DOHRBLkVGNuzth8/5nUCFBtPUlhuUL+TEloDJA2A8zX4epG9Bae3+Q8Y2WB9UFVt36dcZ4ZAVuElK7MZSJPPfK65HI84RjnIQTeaTfp9S5BmOZqCs/sOvr2fL3iB6JOK+7Txz5EZkZcj4B", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Customer ID" = _t, Product = _t, Sales = _t]),
    source = Table.TransformColumnTypes(data,{{"Sales", Currency.Type}}),
    g = Table.Group(source, {"Customer ID"}, {{"sales", each _, type table [Customer ID=nullable text, Product=nullable text, Sales=nullable number, Tag=nullable text]}}),
    tag = Table.AddColumn(g, "Tag", (x) => if x[sales]{[Product="Pd A"]}[Sales] >= 1000000 then "Yes" else "No"),
    expand = Table.ExpandTableColumn(tag, "sales", {"Product", "Sales"}, {"Product", "Sales"})
in
    expand
wickkey
Frequent Visitor

Hi,

 

You can try the if..else statement in the power query using custom column as below:

if [Product] = "Pd A" and [Sales] > 1000000 then "Yes" else "No"

 

wickkey_2-1684082275463.png

 

 

wickkey_1-1684082187595.png

 

Thanks!

This is not what I am looking. I need same tag for all rows for same customer. 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.