Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
i have a table with following columns.
Leave Details
EmployeeName Leave taken days Leave Type Start Date End Date Month diff Created colum
A 5 Work from home 24/12/2018 29/12/2018 1 0
B 120 Vacation Leave 01/06/2018 31/122018 6 0
C 10 Marraige leave 01/06/2018 10/06/2018 1 5
work from home should not consider as a leave, return created column as 0
marraige leave should not consider as a leave if leave taken days <5, want remaining days if leave taken days >5 in a created column.
vacation leave should not consider as a leave if month diffe <=6, return created column as 0.
i tried the following dax query:
Created Column =
SWITCH(TRUE(),
'Leave Details'[Request type] = "Work From Home" && 'Leave Details'[Leave taken days] >0,0,
'Leave Details'[Request type] = "Vacation Leave" && 'Leave Details'[Month diff]=6,'Leave Details'[Month diff]= -6,
'Leave Details'[Request type] = "Marriage" && 'Leave Details'[Leave taken days]>=5,'Leave Details'[Leave taken days] - 5,
'Leave Details'[Request type] = "Vacation Leave" && 'Leave Details'[Month diff]<6,0,
'Leave Details'[Request type] = "Marriage" && 'Leave Details'[Leave taken days]<5,0,
'Leave Details'[Leave taken days]
)
error Occurs : Expressions that yield variant data-type cannot be used to define calculated columns.
Solved! Go to Solution.
@Anonymous,
You may remove the equal sign (=) in expression below.
'Leave Details'[Month diff]= -6,
@Anonymous,
You may remove the equal sign (=) in expression below.
'Leave Details'[Month diff]= -6,
@Anonymous
please try if formula instead of switch. It should fit your requirement. Thanks
Column = if(Sheet2[leavetype]="a"&&Sheet2[leave taken days]>0,0, if(Sheet2[leavetype]="b"&&'Sheet2'[month diff]=6,Sheet2[month diff]-6 ,if(Sheet2[leavetype]="c"&&Sheet2[leave taken days]>=5,Sheet2[month diff]-5,111)))
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |