Forum Discussion
EmilyM2019
Helper II
6 years agoDax help
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 c...
- 6 years ago
Add a column
ColumnAdded = SWITCH(TableX[Customer], "A", TableX[Working days count], "B", TableX[Calendar days count], 0)
Jimmy801
Community Champion
6 years agoHello 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