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

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.

Reply
BalaKiranM
Helper II
Helper II

Dax help in SWITCH

Experts, please help me to fix the below DAX.

 
Type Description =
SWITCH(
'Accrual View'[Type]=11, "Carry Forward",
'Accrual View'[Type]=2, "Earned",
'Accrual View'[Type]=1, "Sick", 'Accrual View'[Type])

 

BalaKiranM_1-1671198903019.png

 

 

 

 

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @BalaKiranM ,

 

1.Assume the Type columm is Number type, please try:

Type Description = 
SWITCH (
    TRUE (),
    'Accrual View'[Type] = 11, "Carry Forward",
    'Accrual View'[Type] = 2, "Earned",
    'Accrual View'[Type] = 1, "Sick",
    CONVERT( 'Accrual View'[Type],STRING)
)

Eyelyn9_1-1672207717795.png

 

2. Text type:

Description =
SWITCH ( [Type], "1", "Sick", "2", "Earned", "11", "Carry Forward", [Type] )

Eyelyn9_2-1672207772122.png

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-eqin-msft
Community Support
Community Support

Hi @BalaKiranM ,

 

1.Assume the Type columm is Number type, please try:

Type Description = 
SWITCH (
    TRUE (),
    'Accrual View'[Type] = 11, "Carry Forward",
    'Accrual View'[Type] = 2, "Earned",
    'Accrual View'[Type] = 1, "Sick",
    CONVERT( 'Accrual View'[Type],STRING)
)

Eyelyn9_1-1672207717795.png

 

2. Text type:

Description =
SWITCH ( [Type], "1", "Sick", "2", "Earned", "11", "Carry Forward", [Type] )

Eyelyn9_2-1672207772122.png

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Jihwan_Kim
Super User
Super User

Hi,

If you are trying to create a new column, please try something like below.

 

Type Description =
SWITCH (
    TRUE (),
    'Accrual View'[Type] = 11, "Carry Forward",
    'Accrual View'[Type] = 2, "Earned",
    'Accrual View'[Type] = 1, "Sick",
    'Accrual View'[Type]
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thanks @Jihwan_Kim But it is erroring out again, please help @amitchandak 

 

BalaKiranM_0-1671201531301.png

 

hi @BalaKiranM @what type of data do you have for the [type] column

It was Number, I changed to text.

the code compares it with number, so it needs to be numbers. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors