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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
magutter
Regular Visitor

Custom Columns

I'm tring to create a custom column which uses  sum(Sales) but want to filter on another column call type where it shows everything EXCEPT Types that equal "JC" or "JD". Tried the following syntax but no joyy. Can anyone help? The sum part is working OK in a previous query but I've for type, i've tried "not in", "does not contain" and "<>" but cannot get the correct syntax.

 

if ([Sales] > 0 and ([TYPE] <> "JC" and [TYPE] <> "JD"))
then [Sales]
else [Net Amount]

5 REPLIES 5
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @magutter,

 

Please try it out in this file. Which measure is the one you want?

Sum1 =
CALCULATE (
    SUM ( Table1[Sales] ),
    FILTER ( ALL ( Table1 ), NOT Table1[Type] IN { "JC", "JD" } )
)
Sum2 =
IF ( [Type] IN { "JC", "JD" }, [Net Amount], Table1[Sales] )
Sum3 =
IF (
    [Type] IN { "JC", "JD" },
    CALCULATE ( SUM ( Table1[Net Amount] ) ),
    CALCULATE (
        SUM ( Table1[Sales] ),
        FILTER ( ALL ( Table1 ), NOT Table1[Type] IN { "JC", "JD" } )
    )
)

Custom_Columns

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Dale

 

Thanks alot for your response. I know how to do it as a measure but what would you suggest when creating a custom column in the query editor. It would appear that custom columns uses "m" query language which I'm struggling with

Which result do you want?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Dale

 

I want it to get the NET figure for Sales but exclude TYPE of "JC" or "JD". I want those types to return a value of 0

Hi @magutter,

 

You can try it like this:

if [Sales] > 0 and [Type] <> "JC" and [Type] <> "JD" 
then [Net Amount]
else 0

Custom_Columns

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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