Using the Formula SUMIF() and WHEN() in Excel - vba

I tried a Formula in Excel for the following condition. In the first line I have the month from January to March. All the values which are corresponding to the months are in the second line. I want to sum up these values. For example the values from month January would be 30.
I got it figured out up to this formula: =WENN(A1:J1;SUMMEWENN(A1:J1;MONAT(1);A2:J2)) . I am searching in the entire row for the month 1 ( January ) but when I copy this for Feb it does not work I get the same result. By the way it is the German version :-)
thx all.

It looks like your top row is formatted as text. If that is the case then this might be a possible solution for you:
For January: =SUMMEWENN($A$1:$J$1,"01",$A$1:$J$1) which would yield 30
For Feb: =SUMMEWENN($A$1:$J$1,"02",$A$1:$J$1) which would yield 17
For March: =SUMMEWENN($A$1:$J$1,"03",$A$1:$J$1) which would yield 26
Let me know if something is unclear.
EDIT:
This second portion might be easier because you can put it in cell A5 then drag it down to cell A7.
=SUMMEWENN($A$1:$J$1,MONAT(DATWERT(A5&"1")),$A$1:$J$1)

You need to freeze the range "A1:J1". Use the below Code
=WENN($A$1:$J$1;SUMMEWENN($A$1:$J$1;MONAT(1);$A$2:$J$2))

Related

TERADATA Query for entire month

I wanted to know if there was a way to extract data from a date column pertaining to an entire month.
SEL * FROM DB.TBLNAME TABLE
WHERE TABLE.DATE_ BETWEEN DATE '01-02-2022' AND DATE ' 28-02-2022'
So in the above query(wrote it here as an example so hope i didnt make any typo mistake) im searching for all dates from the 1st to the 28th of february but wanted to know if there was a more elegant method as to select a month match eg. 02-2022.
I hope my question was detailed enough.
Thanks in advance,
For this you could do something like this to make it easier to develop and change as you would need it
SELECT
*
FROM DB.TBLNAME TABLE
WHERE 1=1
AND MONTH(TABLE.DATE) = 2
AND YEAR(TABLE.DATE) = 2022
This is how I would normally do it as you would then be able to write a python script to go with it or a param to dynamically pull the data you need for the month/year

Apple Numbers sum if is date is in Month

In Apple numbers I tried to sum cells if the date is in a specific month.
So I have a column A with a date and column B has a price.
Date
Price
29-07-2021
12,50
16-06-2021
15,00
I use the function sum.if and the function month that returns the number of the month.
My formule look like this
som.if(month(Date));7;Price);
But this generates an error numbers can only check one date and not for each row for counting.
Is there anybody who can help me with this?
Thanks a lot!
Use SUMPRODUCT() instead. I am using US-EN version of excel. So, decimal separator and formula definition may differ.
=SUMPRODUCT((B2:B3)*(MONTH(A2:A3)=7))
If you want to use SUNIFS() then can try-
=SUMIFS(B2:B3,A2:A3,">="&DATE(2021,7,1),A2:A3,"<="&DATE(2021,7,31))
If you have Excel-365 then can use FILTER() function like-
=SUM(FILTER(B2:B3,MONTH(A2:A3)=7))

conditional formatting with ranges

The image above shows what i am working on. When Putting in a date in the M column, it will then put in the day of the week in the O column. What I want to do is write a conditional formatting code to change the color of the cell in the O column if the day of the week is not there in the F-L columns. For example: in the 2nd picture, Row 14 does not have Fri in the F-L columns. I would want it so because of that, O14 changes fill color.
hope that helps
thank you, W
Have you tried something like this?

Formatting Day Time X Axis in SSRS Charts

I am working on a SSRS report which compares data of 2 given months. I'm categorising the chart based on Day and time in the following format 1, 6:00 AM. I get this column from the T-SQL itself. But the axis does not come properly. It looks like below now which doesn't make sense. I want it to be in order from 1st to 30th with the time component.
I guess I need some kind of sorting on X-axis with respect to date time. Please help!
After deleting from sorts from chart I'm getting some extra repitive dates after comparing all 30 days of both months. Data from the query looks alright to me!
Thank you!
Ok. Large query
You X-axis are show value in format date,hh mm tt Right ?
Then you want to sort them with day number 1 - 30.
From your query I suggest you add 1 field is like this CAST(SampleCollected AS DATE) [orders] and use this field in Order in Query or Sort on SSRS (not recommend ) and if you use Order in Query must delete sort condition on chart sort.
But if result still not you want try to add MONTH(SampleCollected) As MonthG to order again like this
ORDER BY MONTH(SampleCollected),CAST(SampleCollected AS DATE)
Hope it's Help.

Find a previous date on a list closest to a specified date

I would like to have VBA code or formula that will take a variable date value and find it on a list range of dates. If it can't find the date I want it to find the closest previous date value. VLOOKUP works great for finding an exact match but I am struggling with the code to find the closest previous date.
My only thought is to create a loop where if it doesn't match it continues to subtract a day from the variable date until it can locate a match on the list. That does not seem like the best or most efficient method and I hope someone can recommend a simpler solution.
Example:
Variable Date = 01/26/2014
Date List
02/04/2014
01/27/2014
01/24/2014
01/13/2014
12/29/2013
Desired Result = 01/24/2014
Any help would be appreciated.
Suppose your list of dates was in cells A1:A5 and your check date was in cell C1, you could enter this function ENTERED AS AN ARRAY FORMULA:
=MAX(($A$1:$A$5<=C1)*A1:A5)
Rememeber, to enter it as an array formula, hit Ctrl + Shift + Enter when entering the formula.
Hope this does the trick!!
I went about this a little differently, no arrays needed
Find how many numbers are bigger then the one you are looking for with CountIf()
Then I used =Large this will find the nth dates in a list we have the nth we are looking for in the countIF()
=LARGE(A:A,COUNTIF(A:A,">="&TODAY()))
Vlookup can do this actually, if you set the final argument to true, which looks for an approximate match. You need your dates sorted from Oldest to newest and it will return the first date that is not after your search term.