Add-PnPField and -Type Calculated

%3CLINGO-SUB%20id%3D%22lingo-sub-31951%22%20slang%3D%22en-US%22%3EAdd-PnPField%20and%20-Type%20Calculated%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-31951%22%20slang%3D%22en-US%22%3E%3CP%3EWhat's%20the%20format%20for%20creating%20calculated%20fields%20with%20AddPnPField%3F%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20assuming%20the%20%3CSTRONG%3E-Type%3C%2FSTRONG%3E%20should%20be%20%3CSTRONG%3ECalculated.%26nbsp%3B%20%3C%2FSTRONG%3ELike%20this%3A%20%3CSTRONG%3EAdd-PnPField%20-Type%20Calculated%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20have%20the%20formula%26nbsp%3BI%20want%20to%20use%2C%20I%26nbsp%3Bknow%20it%20works%20in%20the%20field%20I%20created%20manually.%26nbsp%3B%20I%26nbsp%3Bwas%26nbsp%3Bgoing%20to%20paste%20it%20in%2C%26nbsp%3Bbut%20not%20sure%20what%20format%20it%20should%20go%20in%20after%20%3CSTRONG%3ECalculated.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20seeing%20this%20error%20when%20I%20add%20the%20formula%20after%20%3CSTRONG%3ECalculated%3C%2FSTRONG%3E%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAdd-PnPField%20%3A%20A%20positional%20parameter%20cannot%20be%20found%20that%20accepts%20argument%20'IF(Likelihood%3D'.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-31964%22%20slang%3D%22en-US%22%3ERe%3A%20Add-PnPField%20and%20-Type%20Calculated%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-31964%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20could%20look%20into%20Add-PnPFieldFromXml%20it%20might%20make%20things%20easier.%20Then%20the%26nbsp%3B-FieldXml%20switch%20needs%20the%20Xml.%20Similar%20as%20used%20by%20the%20PnP%20Templates%20for%20the%20calculated%20columns.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Microsoft

What's the format for creating calculated fields with AddPnPField? 

 

I'm assuming the -Type should be Calculated.  Like this: Add-PnPField -Type Calculated

 

I have the formula I want to use, I know it works in the field I created manually.  I was going to paste it in, but not sure what format it should go in after Calculated.

 

I'm seeing this error when I add the formula after Calculated:

 

Add-PnPField : A positional parameter cannot be found that accepts argument 'IF(Likelihood='.

 

Thanks

1 Reply
Highlighted

You could look into Add-PnPFieldFromXml it might make things easier. Then the -FieldXml switch needs the Xml. Similar as used by the PnP Templates for the calculated columns.