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
Anonymous
Not applicable

Using summarize in 'in' operator

I'm getting error for the following measure:

 

test:=


Var Result =
CALCULATE(
	    [Grade] -- this is a measure, nothing special with this measure, just add grades.
	    ;'fact1'[studentnr_FK] in {​​​​​​​​ 
--here i check for those student who has grade 
	
	   SUMMARIZE( 
	    FILTER('fact1';'fact1'[grade1]>0 || 'fact1'[grade2]>0)
	
                    ;('fact1'[studentnr_FK]) )             ​​​​                          
}
)
	Return
	SWITCH(
	TRUE();
	Result<0;"0";
	Result>0; Result;

)

 

 

 

And I'm getting error:

 

The following syntax error occurred during parsing: Invalid token, Line 7, Offset 44,. 

 

for '{' and '}' in dax code.

 

Should I add something to measure or what is the problem?

There is something with syntax and I don't know what.

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your measure, I guess the error happens in the last “;” in your SWITCH() function, it should be deleted. I also suggest you use Variable to define your summarize table, you can try this measure:

Test =
Var Summarize =
SUMMARIZE(
           FILTER('fact1','fact1'[grade1]>0 || 'fact1'[grade2]>0)
                    ,('fact1'[studentnr_FK]) )             ​​​​
Var Result =
CALCULATE(
           [Grade] -- this is a measure, nothing special with this measure, just add grades.
           ,'fact1'[studentnr_FK] in Summarize
}
)
       Return
       SWITCH(
       TRUE(),
       Result<0,0,
       Result>0, Result
)

 

If you still have a problem, I suggest you can share your sample pbix file(without sensitive data) and your expected result, so that we can help you better. Thanks in advance!

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

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

4 REPLIES 4
PaulDBrown
Community Champion
Community Champion

@Anonymous 

 

Try

test:=
VAR _FiltTable = CALCULATETABLE(
                   VALUES('fact1'[studentnr_FK]),
                    FILTER('fact1',
                    SUM('fact1'[grade1])>0 || SUM('fact1'[grade2])>0))

Var Result =
CALCULATE(
	    [Grade],
             _FiltTable)
	
Return
	SWITCH(
	TRUE();
	Result<0;"0";
	Result>0; Result;

)

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your measure, I guess the error happens in the last “;” in your SWITCH() function, it should be deleted. I also suggest you use Variable to define your summarize table, you can try this measure:

Test =
Var Summarize =
SUMMARIZE(
           FILTER('fact1','fact1'[grade1]>0 || 'fact1'[grade2]>0)
                    ,('fact1'[studentnr_FK]) )             ​​​​
Var Result =
CALCULATE(
           [Grade] -- this is a measure, nothing special with this measure, just add grades.
           ,'fact1'[studentnr_FK] in Summarize
}
)
       Return
       SWITCH(
       TRUE(),
       Result<0,0,
       Result>0, Result
)

 

If you still have a problem, I suggest you can share your sample pbix file(without sensitive data) and your expected result, so that we can help you better. Thanks in advance!

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

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

amitchandak
Super User
Super User

@Anonymous , try like

test:=


Var Result =
CALCULATE(
	    [Grade] -- this is a measure, nothing special with this measure, just add grades.
	    ;'fact1'[studentnr_FK] in
--here i check for those student who has grade 
	
	   SUMMARIZE( 
	    FILTER('fact1';'fact1'[grade1]>0 || 'fact1'[grade2]>0)
	
                    ;('fact1'[studentnr_FK]) )             ​​​​                          
)
	Return
	SWITCH(
	TRUE();
	Result<0;"0";
	Result>0; Result;

)
Anonymous
Not applicable

I did and remove {} but still getting the same error but this time offset 43:

The following syntax error occurred during parsing: Invalid token, Line 7, Offset 43, ​.

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.