cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GunnerJ Member
Member

Help with some Syntax

If someone can help me figure out how to fix my syntax I'd appreciate it. In the picture you can see that powerbi doesn't like my last section where I have the DELAY condition added. If I add it before the "OR" section of code that the error switches to the OR statement. 
 
02.Min.Task Time by SO# = CALCULATE(min('Open SO data'[BI_EVENT_DT_TM]),FILTER(allexcept('Open SO data','Open SO data'[BI_SO_NBR],'Open SO data'[BI_WRKFLW_TASK_SEQ_NBR],'Open SO data'[BI_WORK_EVENT_CD],'Open SO data'[BI_WORKGRP]), or('Open SO data'[BI_WORKGRP] = "CONFOLLOW" ,or('Open SO data'[BI_WORKGRP] = "CONST", 'Open SO data'[BI_WORKGRP] = "SUB")), 'Open SO data'[BI_WORK_EVENT_CD] = "DELAY"))
 
Syntax error.PNG
1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Help with some Syntax

Hi @GunnerJ 

You seem to be using FILTER with three arguments. It takes only two. Try this, where I'm assuming you want and AND

 

02.Min.Task Time by SO# =
CALCULATE (
    MIN ( 'Open SO data'[BI_EVENT_DT_TM] ),
    FILTER (
        ALLEXCEPT (
            'Open SO data',
            'Open SO data'[BI_SO_NBR],
            'Open SO data'[BI_WRKFLW_TASK_SEQ_NBR],
            'Open SO data'[BI_WORK_EVENT_CD],
            'Open SO data'[BI_WORKGRP]
        ),
        OR (
            'Open SO data'[BI_WORKGRP] = "CONFOLLOW",
            OR ( 'Open SO data'[BI_WORKGRP] = "CONST", 'Open SO data'[BI_WORKGRP] = "SUB" )
        )
            && 'Open SO data'[BI_WORK_EVENT_CD] = "DELAY"
    )
)

 or this (I don't know what you are trying to do)

 

02.Min.Task Time by SO# =
CALCULATE (
    MIN ( 'Open SO data'[BI_EVENT_DT_TM] ),
    FILTER (
        ALLEXCEPT (
            'Open SO data',
            'Open SO data'[BI_SO_NBR],
            'Open SO data'[BI_WRKFLW_TASK_SEQ_NBR],
            'Open SO data'[BI_WORK_EVENT_CD],
            'Open SO data'[BI_WORKGRP]
        ),
        OR (
            'Open SO data'[BI_WORKGRP] = "CONFOLLOW",
            OR ( 'Open SO data'[BI_WORKGRP] = "CONST", 'Open SO data'[BI_WORKGRP] = "SUB" )
        )
    ),
    'Open SO data'[BI_WORK_EVENT_CD] = "DELAY"
)

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Help with some Syntax

Hi @GunnerJ 

You seem to be using FILTER with three arguments. It takes only two. Try this, where I'm assuming you want and AND

 

02.Min.Task Time by SO# =
CALCULATE (
    MIN ( 'Open SO data'[BI_EVENT_DT_TM] ),
    FILTER (
        ALLEXCEPT (
            'Open SO data',
            'Open SO data'[BI_SO_NBR],
            'Open SO data'[BI_WRKFLW_TASK_SEQ_NBR],
            'Open SO data'[BI_WORK_EVENT_CD],
            'Open SO data'[BI_WORKGRP]
        ),
        OR (
            'Open SO data'[BI_WORKGRP] = "CONFOLLOW",
            OR ( 'Open SO data'[BI_WORKGRP] = "CONST", 'Open SO data'[BI_WORKGRP] = "SUB" )
        )
            && 'Open SO data'[BI_WORK_EVENT_CD] = "DELAY"
    )
)

 or this (I don't know what you are trying to do)

 

02.Min.Task Time by SO# =
CALCULATE (
    MIN ( 'Open SO data'[BI_EVENT_DT_TM] ),
    FILTER (
        ALLEXCEPT (
            'Open SO data',
            'Open SO data'[BI_SO_NBR],
            'Open SO data'[BI_WRKFLW_TASK_SEQ_NBR],
            'Open SO data'[BI_WORK_EVENT_CD],
            'Open SO data'[BI_WORKGRP]
        ),
        OR (
            'Open SO data'[BI_WORKGRP] = "CONFOLLOW",
            OR ( 'Open SO data'[BI_WORKGRP] = "CONST", 'Open SO data'[BI_WORKGRP] = "SUB" )
        )
    ),
    'Open SO data'[BI_WORK_EVENT_CD] = "DELAY"
)

View solution in original post

GunnerJ Member
Member

Re: Help with some Syntax

@AlB I see my mistake. Thank you for the quick reply!

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 46 members 822 guests
Please welcome our newest community members: