Forum Discussion

sqlguru448's avatar
sqlguru448
Helper III
6 years ago
Solved

DAX simple measure issue

Hello Folks,   I have a simple DAX measure which counts the order keys based on the number of items below is the DAX.   Order_20 = Calculate(DistinctCount('Fact Order'[Order_Key] | Filter('Fact O...
  • Greg_Deckler's avatar
    6 years ago

    Try something like this:

     

    Order_20 = 
      COUNTX(
        DISTINCT(
          SELECTCOLUMNS(
            FILTER('Fact Order'[Items]<=20),
            "__Order_Key",[Order_Key]
          )
        ),
        [__Order_Key]
      )

     

  • MDrabik's avatar
    6 years ago

    The "Filter" statement on a fact table that large will lead to performance issues. The good news is that you can use a simple filter in this CALCULATE formula instead. Try this:

     

    Order_20 = CALCULATE ( DISTINCTCOUNT ( 'Fact Order'[Order_Key] ), 'Fact Order'[Items] <= 20 )

     

    Thanks!

    Matt Drabik