Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Count Function on Direct Query

Hi all,

 

I want to use count function in direct query mode.

I'm unable to use it. The formula does not return an error.

Measure = COUNT('Bölge Yöneticisi'[Bölge Yöneticisi Düzey 01])

when i try to use it on chart I'm getting this error.
Screenshot_2.png

1 ACCEPTED SOLUTION
technolog
Super User
Super User

Firstly, when you're working with DirectQuery in Power BI, you have to remember that not all DAX functions behave the same way as they do in Import mode. DirectQuery sends the DAX calculations as native SQL queries to the source database, so there might be some limitations based on the database you're connected to.

The formula you provided, Measure = COUNT('Bölge Yöneticisi'[Bölge Yöneticisi Düzey 01]), seems straightforward. However, since you're getting an error when trying to use it on a chart, there might be a few reasons for that:

The column 'Bölge Yöneticisi Düzey 01' might have some blank or NULL values. In DirectQuery mode, handling of these values might be different. You might want to try the COUNTA function instead of COUNT if there are non-numeric values in the column.
The data type of the column might be causing an issue. Ensure that the column's data type is appropriate for counting.
There might be a compatibility issue with the underlying database. Some databases might not support certain DAX functions directly. In such cases, you might need to create a custom SQL query or view on the database side and then connect to that view/query in Power BI.
Lastly, ensure that there's no issue with the connection itself. Sometimes, connectivity issues or timeouts can lead to errors when trying to render visuals.
If you've tried all of the above and still face the issue, it would be helpful to know the exact error message you're getting. That would give more context on what might be going wrong. Also, always keep an eye on the Power BI documentation and forums, as they often have solutions for common issues faced by users.

View solution in original post

1 REPLY 1
technolog
Super User
Super User

Firstly, when you're working with DirectQuery in Power BI, you have to remember that not all DAX functions behave the same way as they do in Import mode. DirectQuery sends the DAX calculations as native SQL queries to the source database, so there might be some limitations based on the database you're connected to.

The formula you provided, Measure = COUNT('Bölge Yöneticisi'[Bölge Yöneticisi Düzey 01]), seems straightforward. However, since you're getting an error when trying to use it on a chart, there might be a few reasons for that:

The column 'Bölge Yöneticisi Düzey 01' might have some blank or NULL values. In DirectQuery mode, handling of these values might be different. You might want to try the COUNTA function instead of COUNT if there are non-numeric values in the column.
The data type of the column might be causing an issue. Ensure that the column's data type is appropriate for counting.
There might be a compatibility issue with the underlying database. Some databases might not support certain DAX functions directly. In such cases, you might need to create a custom SQL query or view on the database side and then connect to that view/query in Power BI.
Lastly, ensure that there's no issue with the connection itself. Sometimes, connectivity issues or timeouts can lead to errors when trying to render visuals.
If you've tried all of the above and still face the issue, it would be helpful to know the exact error message you're getting. That would give more context on what might be going wrong. Also, always keep an eye on the Power BI documentation and forums, as they often have solutions for common issues faced by users.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors