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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Trodo7377
Frequent Visitor

Syntax error by adding conditions

I'm using this measure in PBI desktop which works fine:

m_lan= sumx(values('vAbc'[ProjectID]),calculate(DISTINCTCOUNT('vAbc'[ID])))))


But I need to add two conditions and tried to change m_lan as below but getting this error: The following syntax error occurred during parsing: Invalid token, Line 3, Offset 3,  .
New measure(with line number):

1 m_lan = 
2 var lan =CALCULATE(
3        DISTINCTCOUNT('vAbc'[ID]),
4        FILTER('vAbc',
5            'vAbc'[col1] <> "Hello" &&
6            NOT(ISBLANK('vAbc'[col1]))
7        )
8    )
9
10 return SUMX(VALUES('vAbc'[ProjectID]), lan)

 

I've tried to rewrite the measure in many ways but still getting error or wrong result. How can I add those conditions to the original measure? or why I getting this error? 

1 ACCEPTED SOLUTION
Deku
Super User
Super User

m_lan = 

SUMX(

VALUES('vAbc'[ProjectID]),

CALCULATE(

DISTINCTCOUNT('vAbc'[ID]),

FILTER(

All('vAbc'[col1]),

'vAbc'[col1] <> "Hello" &&

NOT iSBLANK( 'vAbc'[col1] )

 )

 )


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

6 REPLIES 6
sjoerdvn
Super User
Super User

Have you tried something like this?

m_lan= CALCULATE(
   sumx(values('vAbc'[ProjectID]),calculate(DISTINCTCOUNT('vAbc'[ID])))
   ,'vAbc'[col1] <> "Hello"
   ,NOT(ISBLANK('vAbc'[col1]))
)

Thank you for your suggestion. I changed measure but it shows the same value for all rows.

yes. was wondering what the sumx was for. But you might have to share more on the data you have and the output you are trying to achieve here.

@Trodo7377 Try this:

 

m_lan =
SUMX(
VALUES('vAbc'[ProjectID]),
CALCULATE(
DISTINCTCOUNT('vAbc'[ID]),
'vAbc'[col1] <> "Hello",
NOT(ISBLANK('vAbc'[col1]))
)
)

 

It's a little different

BBF


💡 Did I answer your question? Mark my post as a solution!

👍 Kudos are appreciated

🔥 Proud to be a Super User!

Community News image 1920X1080.png
Deku
Super User
Super User

m_lan = 

SUMX(

VALUES('vAbc'[ProjectID]),

CALCULATE(

DISTINCTCOUNT('vAbc'[ID]),

FILTER(

All('vAbc'[col1]),

'vAbc'[col1] <> "Hello" &&

NOT iSBLANK( 'vAbc'[col1] )

 )

 )


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Thank you, it worked!🙂

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.