Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hello,
I need help with a simple calculation. In my data source I have 2 date count columns, one is working days and one is calendar days.
I then have a field with a customer. I want a new column that looks at the customer column, and then based on the customer either returns the date count value of working days or calendar days.
So, if 'Customer' = "A"
return value of working days count
if 'Customer' = "B"
return value of calendar days count
| Working days count | Calendar days count | Customer |
| 141 | 196 | A |
| 72 | 101 | B |
| 67 | 94 | A |
| 61 | 84 | C |
| 54 | 75 | C |
| 49 | 68 | A |
I just can't figure out how to do it.
Any help would be appreciated.
Regards,
Solved! Go to Solution.
Add a column
ColumnAdded = SWITCH(TableX[Customer], "A", TableX[Working days count],
"B", TableX[Calendar days count],
0)
Hello @EmilyM2019
if you need a solution in Power Query, here is the solution
Create a new column and add this formula
if [Customer]="A" then [Working days count] else if [Customer]="B" then [Calendar days count] else "0"here the complete solution
let
Source = #table
(
{"Working days count","Calendar days count","Customer"},
{
{"141","196","A"}, {"72","101","B"}, {"67","94","A"}, {"61","84","C"}, {"54","75","C"}, {"49","68","A"}
}
),
AddCustom = Table.AddColumn
(
Source,
"Custom",
each if [Customer]="A" then [Working days count] else if [Customer]="B" then [Calendar days count] else "0"
)
in
AddCustom
Copy paste this code to the advanced editor in a new blank query to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Add a column
ColumnAdded = SWITCH(TableX[Customer], "A", TableX[Working days count],
"B", TableX[Calendar days count],
0)
Thanks for the help. This worked perfectly.
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 5 | |
| 5 | |
| 4 |