Forum Discussion

newpbiuser01's avatar
newpbiuser01
Helper V
1 year ago
Solved

Using Summarize with Countrows and Filter Functions in a Dax Measure

Hello,

 

I am trying to use the countrows function to get the unique count of records in a function. How can I use the I tried using the following function:

#Records = Countrows( Filter( Summarize ('Order Data', 'Order Data'[Order Number], 'Order Data'[Status])), [Status] = "Delivered")) 

But I keep getting an incorrect syntax error saying - "The syntax for ) is incorrect". What am I doing wrong? 

 

How can I use countrows, filter and summarize functions together? 

 

I'd appreciate any help!

 

  • No need for summarize - better stay away from that function, it has lots of dirty secrets

     

    #Records = Countrows(SUMMARIZECOLUMNS('Order Data'[Order Number],TREATAS({"Delivered"},'Order Data'[Status])))
  • Hi,

    Try this

    #Records = Countrows( Filter( Summarize ('Order Data', 'Order Data'[Order Number], 'Order Data'[Status]), [Status] = "Delivered")) 

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi newpbiuser01 

     

    Thank you very much Ashish_Mathur and lbendlin for your prompt reply.

     

    I checked your code carefully and the problem is that there is an extra ")" in the screenshot position. You can try to modify it.

     

     

    The correct code should be as provided by Ashish_Mathur.

     

     

    Or you can try the method provided by lbendlin which will also give you the results you want.

     

    Regards,

    Nono Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • No need for summarize - better stay away from that function, it has lots of dirty secrets

     

    #Records = Countrows(SUMMARIZECOLUMNS('Order Data'[Order Number],TREATAS({"Delivered"},'Order Data'[Status])))
  • Hi,

    Try this

    #Records = Countrows( Filter( Summarize ('Order Data', 'Order Data'[Order Number], 'Order Data'[Status]), [Status] = "Delivered")) 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi newpbiuser01 

     

    Thank you very much Ashish_Mathur and lbendlin for your prompt reply.

     

    I checked your code carefully and the problem is that there is an extra ")" in the screenshot position. You can try to modify it.

     

     

    The correct code should be as provided by Ashish_Mathur.

     

     

    Or you can try the method provided by lbendlin which will also give you the results you want.

     

    Regards,

    Nono Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.