Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

dax help

 - hi ,

      I need count of my bidc column where "all units usa" measure is greater than 10.

      I am not able to write measure inside a calculate function as filter.

      =Calculate(count(dac),[all units usa]>10)   ---this is showing error.. even i tried with variable still getting a error.

     any help ?

     Thanks 

8 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous -

     

    Try something like:

     

    Measure = COUNTX(FILTER('Table'[all units usa] > 10),[dac])
    
    or
    
    Measure = CALCULATE(COUNT('Table'[dac]),FILTER('Table'[all units usa] > 10))

     

    If that does not help, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

    Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      no..its not working...

  • Anonymous 

    What is the error and how is the measure [all units usa] constructed?

    ________________________

    Did I answer your question? Mark this post as a solution, this will help others!.

    Click on the Thumbs-Up icon on the right if you like this reply 🙂

    YouTube, LinkedIn

    • Anonymous's avatar
      Anonymous
      Not applicable

      hist units usa:=TRUNC(SUMX(product, product[historical_qty_usa])/[num distinct periods],2)

       [all units usa]  = CALCULATE([hist units usa],FILTER(all('date'[date_key]), 'date'[date_key]=max('date'[date_key])))

       

      Now i want to create a measure like 

      [usa sku count] =  calculate(count(product[sku]), [all units usa] >1)

      error msg - 

      A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

      hope i am able to clear you the requirement.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous 

        You can't use a measure inside a boolean expression that is used as filter expression. There are certain rules related to this

         Refer to this: https://docs.microsoft.com/en-us/dax/calculate-function-dax

        Apart from this your measure [usa sku count] =  calculate(count(product[sku]), [all units usa] >1) doesn't refer any column which needs to be filtered.