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.
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.
Solved! Go to Solution.
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.
@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;
)
Proud to be a Super User!
Paul on Linkedin.
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.
@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;
)
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, .
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
100 | |
81 | |
70 | |
62 |
User | Count |
---|---|
148 | |
116 | |
104 | |
90 | |
65 |