Forum Discussion
Anonymous
7 years agoNot applicable
Calculated column using multiple conditions
Hi I have columns in a table like Request type and Leave taken days but the request type as work from home should not to be consider as a leave. The maternity leave should not consider as a leav...
- 7 years ago
Anonymous
It seems that your days columns are datatype text.
Change them to number
- 7 years ago
Anonymous,
You may use DAX below.
Column = SWITCH ( 'LEAVE DETAILS'[Request type], "Work FromHome", 0, "Maternity leave", MAX ( 0, 'LEAVE DETAILS'[Leave taken days] - 150 ), "Marriage leave", MAX ( 0, 'LEAVE DETAILS'[Leave taken days] - 5 ) )
Greg_Deckler
7 years agoCommunity Champion
I would use SWITCH
Expected Column = SWITCH(TRUE(), 'Leave Details'[Request type] = "Work From Home" && 'Leave Details'[Leave taken days] >0,0, 'Leave Details'[Request type] = "Maternity" && 'Leave Details'[Leave taken days]>=150,'Leave Details'[Leave taken days] - 150, 'Leave Details'[Request type] = "Marriage" && 'Leave Details'[Leave taken days]>=5,'Leave Details'[Leave taken days] - 5, 'Leave Details'[Request type] = "Maternity" && 'Leave Details'[Leave taken days]<150,0, 'Leave Details'[Request type] = "Marriage" && 'Leave Details'[Leave taken days]<5,0, Leave Details'[Leave taken days] )
- Anonymous7 years agoNot applicable
HI,
error occurs,
Dax comparison operations do not support comparing values of type text with values of type integer. Consider using the VALUE or FORMAT function to convert one of the values.
- themistoklis7 years agoCommunity Champion
Anonymous
It seems that your days columns are datatype text.
Change them to number