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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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