Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Niels_T
Post Patron
Post Patron

How to use SWITCH function

Hello,


I have appended both my credit memo and invoice tables.

 

Now I would like to make an extra column that contains the Document Type which is either credit memo or invoice.

 

I tried doing this with a switch function that goes as followed:

 

Document Type =
SWITCH (
TRUE(),
CONTAINS('$Sales + Cr_Memo Header', '$Sales + Cr_Memo Header'[Posting Description], "Invoice"), "Invoice",
CONTAINS('$Sales + Cr_Memo Header', '$Sales + Cr_Memo Header'[Posting Description], "Credit memo"), "Credit Memo"
)
 
I used the column posting description. This column gives me all the invoice and credit memo values with a number behind it.
 
The logic of the function that I wanted to write is as followed:
 
IF the column post description contains the value invoice then add invoice in the document type column. IF it contains Credit Memo then add Credit Memo in the document type column.
1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

A simpler way to do this would be in the query editor.  Before you append the tables, add a Custom Column with a constant string value in each table called "Document Type" with = "Invoice" or = "Credit Memo".

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
mahoneypat
Microsoft Employee
Microsoft Employee

A simpler way to do this would be in the query editor.  Before you append the tables, add a Custom Column with a constant string value in each table called "Document Type" with = "Invoice" or = "Credit Memo".

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Apparently you don't need to do this before you append  them. I added custom columns and my appended table automatically updated itself.

 

Thanks for the help!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.