• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Query does not tag criteria correctly - Help Please |Power Query|Excel Forum|My Online Training Hub

You are here: Home / Query does not tag criteria correctly - Help Please |Power Query|Excel Forum|My Online Training Hub

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryQuery does not tag criteria correct…
sp_PrintTopic sp_TopicIcon
Query does not tag criteria correctly - Help Please
Avatar
Moshe Arama
Member
Members
Level 0
Forum Posts: 7
Member Since:
September 4, 2022
sp_UserOfflineSmall Offline
1
January 15, 2023 - 6:42 am
sp_Permalink sp_Print

Hello everyone,

I run a query with the addition of a column according to certain criteria (I want to receive the shift according to the opening time of the service call)

Everything works fine except for 2 lines that show night shift instead of morning.

i add 2 picture

sp_PlupAttachments Attachments
  • sp_PlupImage Data_Table.png (84 KB)
  • sp_PlupImage If-condition.png (9 KB)
Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 384
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
2
January 15, 2023 - 3:47 pm
sp_Permalink sp_Print

I suspect that this is due to the fact that you are dealing with texts, not real time values. Could it be that the time 08:40:00 contains a leading space? The text " 08;40:00" will be evaluated as greater than the text "23:00", thus returning "Night"

In Power Query, make sure that you set the data type for the call time column to Date/Time. Then extract the time only into the time_for_shift_sebregation column.

And the code for the added column should use the #time() function. It could look like this:

if [time_for_shift_segregation] >= #time(23,0,0) then "Night" else
if [time_for_shift_segregation] >= #time(15,0,0) then "Evening" else "Morning"

If this makes no sense, please upload a file containing the underlying data and query for what is show shown in your screenshot.

Avatar
Moshe Arama
Member
Members
Level 0
Forum Posts: 7
Member Since:
September 4, 2022
sp_UserOfflineSmall Offline
3
January 15, 2023 - 11:16 pm
sp_Permalink sp_Print

Hi Riny ,

thanks for your answer but i still didn't

Understand how to do that ,

the column already modify as time

And i try to write the formula with the time i didn't succeed

please tell me what you need to see and i will show you

sp_PlupAttachments Attachments
  • sp_PlupImage power-query.PNG (121 KB)
Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 384
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
4
January 15, 2023 - 11:56 pm
sp_Permalink sp_Print sp_EditHistory

Not sure what's going on here. When I try to compare a value in a Time column to a text like "06:00" I get an error. So, I don't understand howe you get PQ to return something else to begin with.

Can you upload the file? Not just a screenshot.

Avatar
Moshe Arama
Member
Members
Level 0
Forum Posts: 7
Member Since:
September 4, 2022
sp_UserOfflineSmall Offline
5
January 16, 2023 - 7:33 pm
sp_Permalink sp_Print

Yes i attached the file

but i hope you can see the query as well

Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 384
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
6
January 16, 2023 - 8:20 pm
sp_Permalink sp_Print

Thanks for the file. Any particular reason why it's in the old xls format?

I couldn't really follow through your query as it connected to files in a folder on your computer. But I took your script and connected it to the table in Sheet1, assuming that this is the data you worked off. You'll find it in the "Table1" query that loads the green table in Sheet3.

At the point where you added the column that "calculates" the Shift, the [time_for_shift_segmentation] column is NOT set to Date. It's still a Text. Corrected that and changed the next step to the formula I mentioned earlier (though I misread segmentation for segregation in my response).
Then the query and/or data generated errors in the last column. I just replaced them wit 00:00:00.

Since the data table did not have the problem records that you showed in your screenshots in it, I added a TEST row with an 08:40:00 time stamp which correctly becomes "Morning".

See attached file (saved as an xlsx, by the way).

Avatar
Moshe Arama
Member
Members
Level 0
Forum Posts: 7
Member Since:
September 4, 2022
sp_UserOfflineSmall Offline
7
January 18, 2023 - 10:31 pm
sp_Permalink sp_Print

Riny thank you its work !

you are the master 🙂

Moshe

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 170
Currently Online: Norilina Harvel, Brenda Krol
Guest(s) 42
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1431
Anders Sehlstedt: 848
Velouria: 574
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 213
A.Maurizio: 202
Aye Mu: 201
Jessica Stewart: 185
Newest Members:
David Collins
Andras Marsi
Orimoloye Funsho
YUSUF IMAM KAGARA
PRADEEP PRADHAN
Vicky Otosnika
Abhishek Singh
Kevin Sojourner
Kara Weiss
And Woox
Forum Stats:
Groups: 3
Forums: 24
Topics: 6047
Posts: 26543

 

Member Stats:
Guest Posters: 49
Members: 31497
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Riny van Eekelen
© Simple:Press —sp_Information
  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
 
  • About My Online Training Hub
  • Contact
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Copyright © 2023 · My Online Training Hub · All Rights Reserved

Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.

Download A Free Copy of 100 Excel Tips & Tricks

excel tips and tricks ebook

We respect your privacy. We won’t spam you.

x