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
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
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.