Forum Discussion

Schwadenfeld's avatar
Schwadenfeld
Icon for Helper I rankHelper I
3 years ago

HELP NEEDED: Formula with multiple conditions needed

Hello! I made a short video so my problem is clear: https://www.loom.com/share/15de82e9a7014cf58e5281b011e4768a

I don't know how I can upload the file itself so I have uploaded it here:
https://we.tl/t-KHwdteLfRc 

I have the following problem. I am trying to replace the values "null" in the last column". I want to exract a value under multiple conditions which are:

- Search for the HIGHEST "14 Day Total Sales Value" of the same EXTRACTED ASIN and then replace "null" with the ADVERTISED ASIN. 
- In this example I filtered already for this EXTRACTED ASIN (for example) and one the bottom we can find the highest value now the other "null" values should be replaced for this the related ADVERTISED ASIN.
- it could be tricky as sometimes there are multiple highest values and related ADVERTISED ASINs then just the first value found should be used.
- if no highest value ( no sales at all) for the related EXTRACTED ASIN can be found then the related ADVERTISED ASIN value of the highest sales of ALL EXTRACTED ASIN Values should be used

let
Source = Table.NestedJoin(#"Sponsored Brands Campaign Repor", {"Date", "Campaign Name"}, #"Test SB", {"Date", "Campaign Name"}, "Sponsored Brands Campaign Repor", JoinKind.LeftOuter),
#"Expanded Sponsored Brands Campaign Repor" = Table.ExpandTableColumn(Source, "Sponsored Brands Campaign Repor", {"Purchased ASIN"}, {"Advertised ASIN"}),
#"Duplicated Column" = Table.DuplicateColumn(#"Expanded Sponsored Brands Campaign Repor", "Campaign Name", "Campaign Name - Copy"),
#"Reordered Columns" = Table.ReorderColumns(#"Duplicated Column",{"Date", "Portfolio name", "Currency", "Campaign Name", "Campaign Name - Copy", "Impressions", "Clicks", "Click-Thru Rate (CTR)", "Cost Per Click (CPC)", "Spend", "Total Advertising Cost of Sales (ACOS) ", "Total Return on Advertising Spend (ROAS)", "14 Day Total Sales", "14 Day Total Orders (#)", "14 Day Total Units (#)", "14 Day Conversion Rate", "Viewable impressions", "View-through rate (VTR)", "Click-through rate for views (vCTR)", "Video first quartile views", "Video midpoint views", "Video third quartile views", "Video complete views", "Video unmutes", "5-second views", "5 Second View Rate", "14-Day Branded Searches", "14-day Detail Page Views (DPV)", "14 Day New-to-brand Orders (#)", "14 Day % of Orders New-to-brand", "14 Day New-to-brand Sales", "14 Day % of Sales New-to-brand", "14 Day New-to-brand Units (#)", "14 Day % of Units New-to-brand", "14 Day New-to-brand Order Rate", "Advertised ASIN"}),
#"Extracted Text Between Delimiters" = Table.TransformColumns(#"Reordered Columns", {{"Campaign Name - Copy", each Text.BetweenDelimiters(_, "- B0", " -"), type text}}),
#"Added Custom" = Table.AddColumn(#"Extracted Text Between Delimiters", "Custom", each "B0"),
#"Reordered Columns1" = Table.ReorderColumns(#"Added Custom",{"Date", "Portfolio name", "Currency", "Campaign Name", "Campaign Name - Copy", "Custom", "Impressions", "Clicks", "Click-Thru Rate (CTR)", "Cost Per Click (CPC)", "Spend", "Total Advertising Cost of Sales (ACOS) ", "Total Return on Advertising Spend (ROAS)", "14 Day Total Sales", "14 Day Total Orders (#)", "14 Day Total Units (#)", "14 Day Conversion Rate", "Viewable impressions", "View-through rate (VTR)", "Click-through rate for views (vCTR)", "Video first quartile views", "Video midpoint views", "Video third quartile views", "Video complete views", "Video unmutes", "5-second views", "5 Second View Rate", "14-Day Branded Searches", "14-day Detail Page Views (DPV)", "14 Day New-to-brand Orders (#)", "14 Day % of Orders New-to-brand", "14 Day New-to-brand Sales", "14 Day % of Sales New-to-brand", "14 Day New-to-brand Units (#)", "14 Day % of Units New-to-brand", "14 Day New-to-brand Order Rate", "Advertised ASIN"}),
#"Merged Columns" = Table.CombineColumns(#"Reordered Columns1",{"Custom","Campaign Name - Copy"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Extracted ASIN"),
#"Removed Columns" = Table.RemoveColumns(#"Merged Columns",{"Portfolio name", "Currency", "Impressions", "Clicks", "Click-Thru Rate (CTR)", "Cost Per Click (CPC)", "Total Return on Advertising Spend (ROAS)", "14 Day Total Units (#)", "14 Day Conversion Rate", "Viewable impressions", "View-through rate (VTR)", "Click-through rate for views (vCTR)", "Video first quartile views", "Video midpoint views", "Video third quartile views", "Video complete views", "Video unmutes", "5-second views", "5 Second View Rate", "14-Day Branded Searches", "14-day Detail Page Views (DPV)", "14 Day New-to-brand Orders (#)", "14 Day % of Orders New-to-brand", "14 Day New-to-brand Sales", "14 Day % of Sales New-to-brand", "14 Day New-to-brand Units (#)", "14 Day % of Units New-to-brand", "14 Day New-to-brand Order Rate", "Spend", "Total Advertising Cost of Sales (ACOS) ", "14 Day Total Orders (#)"}),
#"Filtered Rows" = Table.SelectRows(#"Removed Columns", each ([Extracted ASIN] = "B09H5VCT2W"))
in
#"Filtered Rows"



4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Schwadenfeld ,

    The data you see in the Power Query Editor screen is a preview, it doesn't actually end up saving the data, so this is what I show when I open it.

    You may consider providing sanitized data source files (.xlsx) along with the pbix files. Or consider entering simulated data in Power Query Editor to create tables.

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data

    • Schwadenfeld's avatar
      Schwadenfeld
      Icon for Helper I rankHelper I

      Hi, sure, can you tell me how I can attach the files here? I can't find any button to attach files here, only pictures and links. Thank you.