Forum Discussion
Conditional Column: IF Statement with column values embedded in result text
- 4 years ago
No problem, thought I'd ask 🙂
I think the column formula you want is something like this:
if [Opened vs 1st Time Recorded] < 0 then Text.Combine({"The timesheet indicates... ", Text.From(Date.From([TimeDate])), " prior to...", Text.From(Date.From([OpenDate])), " by ", Text.From([Opened vs 1st Time Recorded]), ". Confirm..."}) else nullPete
Hi Jennifer786 ,
Quick question: have you tried using the Smart Narrative visual? This is exactly what it does using DAX measures.
Pete
Thanks Pete! I'm kind of double jobbing here and want to run this query into excel too. The dataset is huge so I'm trying to resolve it on the query side
- BA_Pete4 years agoSuper User
No problem, thought I'd ask 🙂
I think the column formula you want is something like this:
if [Opened vs 1st Time Recorded] < 0 then Text.Combine({"The timesheet indicates... ", Text.From(Date.From([TimeDate])), " prior to...", Text.From(Date.From([OpenDate])), " by ", Text.From([Opened vs 1st Time Recorded]), ". Confirm..."}) else nullPete
- Jennifer7864 years agoFrequent Visitor
Omg thanks Pete that was perfect!
So you nested the Text.Combine within the IF statement which is exactly what I wanted! Did you have to use anything to nest the formulas or does Power query just recognise the formula and where it ends with the 'else' in the IF statement?
- BA_Pete4 years agoSuper User
Power query IF statements are divided by the keywords 'if'...'then'...['else if']...'else'.
You can put anything in between them (within reason!) and PQ will distinguish the calculation/functional segment from the IF-clause transition.
Pete