Forum Discussion
RasmusN532
2 years agoHelper I
Power BI - Power Query combining two columns and with IF statement help
Hi all! I cant seem to get this to work, I´ve browsed some forum posts and thought this would work. I want to create a column by combining two columns. However line_no can be null and if thats t...
- 2 years ago
Hi RasmusN532
If you're using the Custom Column dialog box, this code should work:
[order_no] & "_" & [line_no] ?? [order_no]I've used the coalesce operator "??". If it is just line_no that can be null, then you could also write:
if [line_no] = null then [order_no] else [order_no] & "_" & [line_no]The M language is case-sensitive so keywords like "if" must be lowercase.
Does this help?
Regards
OwenAuger
2 years agoSuper User
Hi RasmusN532
If you're using the Custom Column dialog box, this code should work:
[order_no] & "_" & [line_no] ?? [order_no]
I've used the coalesce operator "??". If it is just line_no that can be null, then you could also write:
if [line_no] = null then [order_no] else [order_no] & "_" & [line_no]
The M language is case-sensitive so keywords like "if" must be lowercase.
Does this help?
Regards
- RasmusN5322 years agoHelper I
Thank you! It worked now