SUMIFS+less than problem

classified

New Member
Joined
Sep 5, 2019
Messages
2
Hi everyone,
I have a data table called "Order" in which a column of its raw data are strings of date; ie. 20191015 (YYYYMMDD).
So I added 3 columns to the table to extracts its Y/M/D using LEFT/RIGHT formulas ie. LEFT(RIGHT([@Date String],4),2) is Column [M].
Then I tried to sum the amount of finished goods weight at the end of each month with some criteria of the products using the following formula:

=SUMIFS(Order[FG Weight],....,Order[Y],YEAR($B5),Order[M],MONTH($B5),Order[D],"<=31")

where B5 is Excel-format date value

The result turns out to be 0 for all months and when I tried removing the date part (Order[D],"<=31"), it worked fine.
So I suspected the problem rooted from the fact that my date source is formula-based.

Does anyone know a solution to this?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
When you use LEFT\RIGHT functions, they extract text strings. Even though the results "look" like numeric values, they are actually strings. So you cannot use a <=31 comparison with a string.

The simple solution is to convert the string results of your LEFT \RIGHT formulas to numeric values by multiplying them by 1. Then Excel will coerce the strings into numeric values e.g.;

LEFT(RIGHT([@Date String],4),2)*1

The YEAR and MONTH comparisons probably worked because they were a simple text-to-text equals comparison and not a greater than or less than comparison if that makes sense.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top