Forum Discussion

wbarnes's avatar
wbarnes
Frequent Visitor
1 year ago
Solved

I keep getting Syntax errors, can someone help me please?

Here's my measure: 

Provider ID =
IF(
    ISBLANK(
        LOOKUPVALUE(
            'Provider Lookup'[Provider ID],
            'Provider Lookup'[Provider Name],
            'Code Stroke DDR'[Who provided Telestroke Service]
        )
    ),
    "No ID",  -- Default text value for blank entries
    FORMAT(
        LOOKUPVALUE(
            'Provider Lookup'[Provider ID],
            'Provider Lookup'[Provider Name],
            'Code Stroke DDR'[Who provided Telestroke Service]
        ),
        "General Number"  -- Converts numeric values to text
    )
)
Here's the Syntax Error: 
The following syntax error occurred during parsing: Invalid token, Line 4, Offset 5,  .
  • Hi wbarnes ,

    In DAX, string outputs in a measure must be returned as a DAX expression, not as comments (i.e., you can’t use -- for comments inside the formula). Also, "General Number" is not a valid format string for FORMAT—use "#" or just wrap the number in FORMAT without a format string.

    Provider ID =
    VAR ProviderID = 
        LOOKUPVALUE(
            'Provider Lookup'[Provider ID],
            'Provider Lookup'[Provider Name],
            'Code Stroke DDR'[Who provided Telestroke Service]
        )
    RETURN
    IF(
        ISBLANK(ProviderID),
        "No ID",
        FORMAT(ProviderID, "")
    )
    

2 Replies

  • Hi wbarnes ,

    In DAX, string outputs in a measure must be returned as a DAX expression, not as comments (i.e., you can’t use -- for comments inside the formula). Also, "General Number" is not a valid format string for FORMAT—use "#" or just wrap the number in FORMAT without a format string.

    Provider ID =
    VAR ProviderID = 
        LOOKUPVALUE(
            'Provider Lookup'[Provider ID],
            'Provider Lookup'[Provider Name],
            'Code Stroke DDR'[Who provided Telestroke Service]
        )
    RETURN
    IF(
        ISBLANK(ProviderID),
        "No ID",
        FORMAT(ProviderID, "")
    )
    
  • wbarnes's avatar
    wbarnes
    Frequent Visitor

    Hi rohit1991,

    That worked perfectly, and thanks for the explanation as to why my measure was not working!!!