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
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
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.