Forum Discussion
How to apply condition on data
This is the column where I have to apply condition in powerbi. I need a custom column which shows the category. Condition is (1, A-B 1, Z-Z 1 ) these values will belong to category1 . Similarly category2 is (2, A-B 2, Z-Z 2) . So my data has about to 5, I can use if condition but in future there might be additional category added. So how do I apply a dynamic condition where my data is combination on text and numbers.
- Anonymous2 years ago
Hi User1999 ,
Below is my table:
The following DAX might work for you:
Category = var A = RIGHT('Table'[Character],1) var B = IF(LEN('Table'[Character]) > 1 , LEFT('Table'[Character],4) , BLANK()) RETURN IF(A < "5",CONCATENATE("Category",A),BLANK())When subsequently adding new text, you only need to change the number of determination conditions for A
The final output is shown in the following figure:
Best Regards,
Xianda Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- AnonymousNot applicable
Hi User1999 ,
Below is my table:
The following DAX might work for you:
Category = var A = RIGHT('Table'[Character],1) var B = IF(LEN('Table'[Character]) > 1 , LEFT('Table'[Character],4) , BLANK()) RETURN IF(A < "5",CONCATENATE("Category",A),BLANK())When subsequently adding new text, you only need to change the number of determination conditions for A
The final output is shown in the following figure:
Best Regards,
Xianda Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.