Period query (1 Viewer)

Gismo

Registered User.
Local time
Today, 21:49
Joined
Jun 12, 2017
Messages
1,298
Hi all,

I need to filter a query with periods from another table
I only want to see the transaction from and to period

My formula does not seem to work

Below is the result of the query before filtering
Query1 Query1

PeriodTotal Sales (UGX)Total Purchase (UGX)Period1Year FromYear To
Jan 2022UGX 552000UGX 4063226,2101 2022Jul 2021Jun 2022
Feb 2022UGX 5388200UGX 603393,602 2022Jul 2021Jun 2022
Mar 2022UGX 9616200UGX 29180003 2022Jul 2021Jun 2022
Apr 2022UGX 4150000UGX 1817739,8304 2022Jul 2021Jun 2022
May 2022UGX 11118400UGX 415278605 2022Jul 2021Jun 2022
Jun 2022UGX 7212200UGX 115095006 2022Jul 2021Jun 2022
Jul 2022UGX 648000UGX 2553440,4707 2022Jul 2021Jun 2022
Aug 2022UGX 3776200UGX 2980255,3708 2022Jul 2021Jun 2022

I only want to see transection >= Year From and <= Year To

>=[Financial Year]![Year From] And <=[Financial Year]![Year To]

1669019911014.png
 

CJ_London

Super Moderator
Staff member
Local time
Today, 19:49
Joined
Feb 19, 2013
Messages
16,618
My formula does not seem to work
Please get into the habit of stating what 'does not work' means, otherwise we are guessing

My best guess is I don't see a table or query called 'Financial Year'
 

Minty

AWF VIP
Local time
Today, 19:49
Joined
Jul 26, 2013
Messages
10,371
What data type is your Period data and where does [Financial Year] table come into things?

Edit - @CJ_London beat me to it
 

ebs17

Well-known member
Local time
Today, 20:49
Joined
Feb 7, 2020
Messages
1,949
Code:
? "Jan 2022">"Jul 2021", "Jan 2022"<"Jun 2022", #1/1/2022#>=#7/1/2021#, #1/1/2022#<#7/1/2022#
Falsch        Wahr          Wahr          Wahr
"Jan 2022" is a string, resulting of Format command. Sorting and comparing strings is done differently than numbers, from the left with the first, then second, ... character.

A full date is internally a number, so it will sort and compare in ways you'd expect.
 
Last edited:

Gismo

Registered User.
Local time
Today, 21:49
Joined
Jun 12, 2017
Messages
1,298
Please get into the habit of stating what 'does not work' means, otherwise we are guessing

My best guess is I don't see a table or query called 'Financial Year'
Apologies, I change to below

>=[Financial Summary]![Year From] And <=[Financial Summary]![Year To]

When I run the query, I only get June and July 2022 as a result
 

CJ_London

Super Moderator
Staff member
Local time
Today, 19:49
Joined
Feb 19, 2013
Messages
16,618
The point about post #4 is you have turned a number into a string - and strings sor differently to numbers/dates.
Strongly recommend you do no formatting until you have got the results you want and ideally in the form or report, not the query. Or if you want to format, format in a way that gives you the order you want. With text 'April' comes before 'January' whereas 'Mth4' with come after 'Mth1'.

And whilst you are at it, take a look at your period format. '02 2021' will come after '01 2022'
 

Gismo

Registered User.
Local time
Today, 21:49
Joined
Jun 12, 2017
Messages
1,298
The point about post #4 is you have turned a number into a string - and strings sor differently to numbers/dates.
Strongly recommend you do no formatting until you have got the results you want and ideally in the form or report, not the query. Or if you want to format, format in a way that gives you the order you want. With text 'April' comes before 'January' whereas 'Mth4' with come after 'Mth1'.

And whilst you are at it, take a look at your period format. '02 2021' will come after '01 2022'
Thank you for that info

Still I am a but lost as the what I should do to get the required result
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 13:49
Joined
Feb 28, 2001
Messages
27,192
What you have done is take a (probably) usable date field and converted it to a display field that follows different rules.

You said you got "Jan 2021" by converting something. You should not have done the conversion. Instead you should have used the raw dates to determine your period using your "BETWEEN...AND" syntax. BUT once you have a query to find your desired period, there is nothing to stop you from repeating the date in another field with your FORMAT function to provide the displayable date as a separate field.
 

Gismo

Registered User.
Local time
Today, 21:49
Joined
Jun 12, 2017
Messages
1,298
What you have done is take a (probably) usable date field and converted it to a display field that follows different rules.

You said you got "Jan 2021" by converting something. You should not have done the conversion. Instead you should have used the raw dates to determine your period using your "BETWEEN...AND" syntax. BUT once you have a query to find your desired period, there is nothing to stop you from repeating the date in another field with your FORMAT function to provide the displayable date as a separate field.
Thank you very much
 

Users who are viewing this thread

Top Bottom