Conditional Formatting and Power Query

%3CLINGO-SUB%20id%3D%22lingo-sub-1343631%22%20slang%3D%22en-US%22%3EConditional%20Formatting%20and%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1343631%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20there%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20struggling%20with%20Conditional%20Formatting%20and%20Power%20Query.%3C%2FP%3E%3CP%3EShort%20question%20is%20...%20is%20there%20a%20way%20to%20prevent%20conditional%20formatting%20from%20shifting%20in%20a%20Power%20Query-based%20table%20when%20adding%2Fremoving%2Freordering%20columns%20in%20PowerQuery%3F%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI%20can%20add%20or%20remove%20additional%20columns%20to%20table%20after%20loaded%20data%20from%20Power%20Query%2C%20and%20conditional%20formatting%20formulas%20recalculate%20applicable%20cells%20and%20stays%20fine.%3C%2FP%3E%3CP%3EHowever%2C%20if%20I%20reorder%2Fadd%2Fremove%20columns%20to%20source%20data%20in%20PowerQuery%20and%20reload%20data%20to%20Excel%20table%2C%20the%20conditional%20formatting%20goes%20mad%20and%20formulas%20apply%20to%20the%20unintended%20column.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example%2C%20if%20formula%20paints%20red%20cells%20based%20on%20formula%20%E2%80%9C%3DAND(%24P13%E2%80%B3United%20States%E2%80%9D%3B%24O13%26lt%3B%E2%80%B3200%E2%80%9D)%2C%20applying%20to%20columns%20%E2%80%9CCountry%E2%80%9D%20(%24P)%20and%20%E2%80%9CSales%E2%80%9D%20(%24O)%2C%20if%20then%20add%2Fremove%2Freorder%20columns%20in%20PowerQuery%20source%20and%20reload%20data%2C%20coloring%20applies%20to%20i.e.%20%E2%80%9CProduct%E2%80%9D%20(now%20in%20%24P)%20and%20%E2%80%9CPopulation%E2%80%9D%20(now%20in%20%24O)%2C%20instead%20of%20%E2%80%9CCountry%E2%80%9D%20(now%20in%20%24Q)%20and%20%E2%80%9CSales%E2%80%9D%20now%20in%20%24B)%2C%20breaking%20the%20whole%20thing.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20%3DAND(MyTable%5BCountry%5D%E2%80%9DUnited%20States%E2%80%9D%3BMyTable%5BSales%5D%26lt%3B%E2%80%9D200%E2%80%9D)%20but%20such%20formula%20is%20not%20accepted%20in%20the%20conditional%20formatting.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1343631%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1343819%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Formatting%20and%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1343819%22%20slang%3D%22en-US%22%3ETry%20if%20this%20helps%3A%3CBR%20%2F%3ERight-click%20the%20table%20in%20question%20and%20choose%20Table%2C%20%22External%20data%20properties...%22.%20Set%20the%20table%20to%20%22Overwrite%20existing%20cells%20with%20new%20data%2C%20clear%20unused%20cells%22.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1359695%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Formatting%20and%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1359695%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F22322%22%20target%3D%22_blank%22%3E%40Jan%20Karel%20Pieterse%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%20that%20option%20did%20it%20actually%20did%20not%20solve%20the%20problem%2C%20but%20was%20really%20close%20(I%20guess%20the%20intent%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%20)%20!!%3C%2FP%3E%3CP%3EIt%20works%20for%20my%20scenario%20to%20tick%20the%20%22Preserve%20column%20sort%2Ffilter%2Flayout%22.%3C%2FP%3E%3CP%3EThat%20allows%20moving%20columns%20around%20in%20Excel%20itself%2C%20respecting%20the%20conditional%20formatting%20formulas%2C%20or%20hiding%20columns%20as%20needed%2C%20instead%20of%20touching%20the%20PowerQuery%20results%20and%20breaking%20the%20column%20sorting%20and%20conditional%20formatting%20of%20resulting%20data%20table.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20a%20lot!%3CBR%20%2F%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi there,

 

I am struggling with Conditional Formatting and Power Query.

Short question is ... is there a way to prevent conditional formatting from shifting in a Power Query-based table when adding/removing/reordering columns in PowerQuery?


I can add or remove additional columns to table after loaded data from Power Query, and conditional formatting formulas recalculate applicable cells and stays fine.

However, if I reorder/add/remove columns to source data in PowerQuery and reload data to Excel table, the conditional formatting goes mad and formulas apply to the unintended column.

 

For example, if formula paints red cells based on formula “=AND($P13″United States”;$O13<″200”), applying to columns “Country” ($P) and “Sales” ($O), if then add/remove/reorder columns in PowerQuery source and reload data, coloring applies to i.e. “Product” (now in $P) and “Population” (now in $O), instead of “Country” (now in $Q) and “Sales” now in $B), breaking the whole thing.

 

I tried =AND(MyTable[Country]”United States”;MyTable[Sales]<”200”) but such formula is not accepted in the conditional formatting.

 

Thanks!

2 Replies
Highlighted
Try if this helps:
Right-click the table in question and choose Table, "External data properties...". Set the table to "Overwrite existing cells with new data, clear unused cells".
Highlighted

@Jan Karel Pieterse 

 

Thanks, that option did it actually did not solve the problem, but was really close (I guess the intent ) !!

It works for my scenario to tick the "Preserve column sort/filter/layout".

That allows moving columns around in Excel itself, respecting the conditional formatting formulas, or hiding columns as needed, instead of touching the PowerQuery results and breaking the column sorting and conditional formatting of resulting data table.

 

Thanks a lot!