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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
User1999
Regular Visitor

How to apply condition on data

423132f3-720c-4346-a515-a1bece00dfde.jpeg

 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. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @User1999 ,

Below is my table:

vxiandatmsft_0-1710294234432.png

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:

vxiandatmsft_2-1710294396458.png

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.

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @User1999 ,

Below is my table:

vxiandatmsft_0-1710294234432.png

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:

vxiandatmsft_2-1710294396458.png

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.

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors