cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper III
Helper III

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
Super User III
Super User III

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

View solution in original post

thanks

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors