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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
bsheffer
Continued Contributor
Continued Contributor

error with if and calculate

trying to replace the total in a grid

 

using this measure:

 

Merchant MultiProduct Flag =
if(isinscope('Dim View_MID_Properties'[MERCHANT_NUMBER]), if([Merchant Product distinctcount] >= 2, 1, 0), calculate([merchant_number count], [Merchant Product distinctcount] > 1))
 
get this error:
 
The report measure 'Dim view_mid_properties[Merchant MultiProduct Flag] has a syntax or semantic error at line 2, position 143, reported by Analysis Services: 'A function 'Calculate' has been used in a true/false expression that is used as a table filter expression.  This is not allowed.
 
how do I correct this?
 
Merchant MultiProduct Flag =
if(isinscope('Dim View_MID_Properties'[MERCHANT_NUMBER]), if([Merchant Product distinctcount] >= 2, 1, 0), 5) puts a 5 in the total line
 
Merchant Product distinctcount = calculate(
DISTINCTCOUNTNOBLANK('Dim Latest Product Per Mid'[Product_Code_and_Name]))
it uses a calculate statement so I don't understand why the calculate that follows gives an error
 
1 ACCEPTED SOLUTION

HI @bsheffer ,,

 

Measure = 

calculate([merchant_number count],  FILTER (Dim View_MID_Properties', [Merchant Product distinctcount] > 1))

 

Regards,

HN

View solution in original post

4 REPLIES 4
harshnathani
Community Champion
Community Champion

Hi @bsheffer ,

 

 

Try this

 

Merchant MultiProduct Flag =
SWITCH (
    TRUE (),
    ISINSCOPE ( 'Dim View_MID_Properties'[MERCHANT_NUMBER] )
        && [Merchant Product distinctcount] >= 2, 1,
    ISINSCOPE ( 'Dim View_MID_Properties'[MERCHANT_NUMBER] )
        && [Merchant Product distinctcount] < 2, 0,
    5
)

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

no it still has issues with the 

calculate([merchant_number count], [Merchant Product distinctcount] > 1)
when I replace the 5 with it.
 
btw merchant_number_count is
merchant_number count = count('Dim View_MID_Properties'[MERCHANT_NUMBER])

HI @bsheffer ,,

 

Measure = 

calculate([merchant_number count],  FILTER (Dim View_MID_Properties', [Merchant Product distinctcount] > 1))

 

Regards,

HN

thanks

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors