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
mboschbe
Helper I
Helper I

Calculated column with condition

Hello Everyone!

 

First of all, thanks for alwayg being so helpful!

 

I am trying to find a formula to determinate if an order is normal or customized.

 

If my order number contains product type 1 and 2 should be considered as "Custom", otherwise if it only contains 1 should be considered as "Normal order"

 

This is how my table looks:

 

ORDERPRODUCT TYPEORDER TYPE
101CUSTOM
102CUSTOM
121NORMAL
131CUSTOM
132CUSTOM
141NORMAL
151NORMAL
161CUSOTM
162CUSTOM

 

Which formula could I use?

 

Lot of thanks!

 

1 ACCEPTED SOLUTION

Hi @mboschbe ,

 

Try this measure:

Measure 2 =
VAR type_no =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[PRODUCT TYPE] ),
        ALLEXCEPT ( 'Table', 'Table'[ORDER] )
    )
RETURN
    IF ( type_no > 1, "CUSTOM", "NORMAL" )

test_Calculated column with condition.PNG

 

Best Regards,
Liang
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

3 REPLIES 3
az38
Community Champion
Community Champion

Hi @mboschbe 

try

Column =
var _custom = CALCULATE(COUNTROWS(Table), ALLEXCEPT(Table, Table[ORDER]), Table[PRODUCT TYPE] = 2)
RETURN
IF (_custom  > 0, "Custom", "Normal order")

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hello!

Thanks for your answer.

 

I have a problem with the formula as it's indicating order as "Custom" if order has two rows instead of indicating Custom when it has type 2.

 

How could I fixed?

 

Thanks!

Hi @mboschbe ,

 

Try this measure:

Measure 2 =
VAR type_no =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[PRODUCT TYPE] ),
        ALLEXCEPT ( 'Table', 'Table'[ORDER] )
    )
RETURN
    IF ( type_no > 1, "CUSTOM", "NORMAL" )

test_Calculated column with condition.PNG

 

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

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.