Forum Discussion

kmei001's avatar
kmei001
Frequent Visitor
4 years ago

COUNTROWS Error

 I am using trying to use the CountRows function in an expression to show all selected values of a parameter in a Paginated Report

 

The function I have seen online from others is: IIF(COUNTROWS("Table1") = (Parameters!Table1.Count), "All", JOIN(Parameters!Table1Supplier.Value, ", "))

 

However this yields an error "Object reference not set to an instance of an object". 

 

When I try to break down the expression, I can use =COUNTROWS("Table1") to get a value. But when I try to add anything else to this expression, the error gets thrown. If I try, =IF(COUNTROWS("Table1") > 1..... this is an error. If i try, =2+COUNTROWS("Table1"), this is an error.

 

Can anyone help?

2 Replies

  • littlemojopuppy's avatar
    littlemojopuppy
    Community Champion

    Hi kmei001 

     

    That's not a formula for Power BI.  Might be Access?  Might be SSRS?  Guessing from the IIF function.

    Based on the description of your issue being "an expression to show all selected values of a parameter in a Paginated Report" a DAX expression that would work is something like this

    CONCATENATEX(
    	VALUES(Parameters[FieldName])
    	", "
    )

    Hope this helps...

     

     

  • v-chenwuz-msft's avatar
    v-chenwuz-msft
    Community Support

    Hi kmei001 ,

     

    I have tested and this works for me, can you share more detail about this, what is the error when IF(COUNTROWS("Table1") > 1?

    Best Regards

    Community Support Team _ chenwu zhu