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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MrDannyHarry
Regular Visitor

Direct Query Function not allowed

Hi All,

 

I have a DAX expression which I am using on a new measure.

This worked  previosuly on data imported but now using direct query I have the following error.

 

Function 'HOUR' is not allowed as part of calculated column DAX expressions on DirectQuery models

 

My Expression is the following:

 

 

TotalTalk Time = var total = sum('database_single   public   mb_callstats'[call_servicing_sec]) var hours = int(total/3600) var minutes = int(mod(total, 3600)/60) var seconds = mod(mod(total, 3600),60) return hours & " hours " & minutes & " minutes " & seconds & " seconds" 

 

 

6 REPLIES 6
Anonymous
Not applicable

Hi @MrDannyHarry 

I build a table in SQL to have a test by your dax expression.

1.png

Result:

2.png

TotalTalk Time is calculated column and TotalTalk Time2 is measure. I can get the correct result both of two.

Here I have some advice.

Please check the version of your Power Bi Desktop.

The latest version:

3.png

If your version is not the latest one, you may update and try again.

Click this link to download : Download

If this reply still couldn't help you solve your problem, please show me more details about your issue. You may provide me the screenshot of your issue, the dax tou use and the error it shows. And you may show me your data model as well.

 

Best Regards,

Rico Zhou

 

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

 

@Anonymous 

 

Thanks for your help!

I have the latest version, I have copied your code and still getting the same error.

 

You can see the measure below.

MrDannyHarry_0-1597306944954.png

The code in this measure is the same as you supplied.

MY DB Tables show this data

MrDannyHarry_1-1597307218083.png

 

I then use the following command in a custom column to convert to seconds

 

call_servicing_sec = SECOND('database_single   public   mb_callstats'[call_servicing]) + MINUTE('database_single   public   mb_callstats'[call_servicing]) * 60 + HOUR('database_single   public   mb_callstats'[call_servicing]) * 3600

 

 

The only differnce is I am using a third party ODBC DirectQuery connector for Postgres.

I couldn't use the main Postgres connector as it had a certificate error. Could this be the issue?

 

I have got past this by getting Postgres Direct Query to work  instead of ODBC Direct Query.

 

I am getting a Folding error now when trying to add visuals with calculations.

Anonymous
Not applicable

Hi @MrDannyHarry 

Could you show me more details? Such as your issue Screenshot, the calculations you build, the visual you want to build and the underlying data sample you use.

Best Regards,

Rico Zhou

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

amitchandak
Super User
Super User

@MrDannyHarry , I checked on the Direct query file. Hours is supported on a column

 

I used in a direct query -

 hour(Sales[Sales Date])
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
parry2k
Super User
Super User

@MrDannyHarry are you creating a measure or a column? I don't see HOUR function used in the expression you shared, little bit lost in the question and expression you shared.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.