简体   繁体   中英

Google sheets transform if statement into arrayformula

How do you transform the below into an arrayformula that drags down according to all BA column and N column?

= IFS( ISBLANK($AD$2), IFS(N3="April 2020",(BA3/60)*$AD$3, N3="May 2020",(BA3/60)*$AD$4, N3="June 2020",(BA3/60)*$AD$5, N3="July 2020",(BA3/60)*$AD$6, N3="August 2020",(BA3/60)*$AD$7, N3="September 2020",(BA3/60)*$AD$8,N3="October 2020",(BA3/60)*$AD$9,N3="November 2020",(BA3/60)*$AD$10,N3="December 2020",(BA3/60)*$AD$11), NOT (ISBLANK($AD$2)), (BA3/60)*$AD$2)

https://docs.google.com/spreadsheets/d/1Z6d8SbFc5iO07pYgiudI9CR84PrwUWc5Q5wQpWKLWFc/edit#gid=0 It is the formula in cell F2

Does this work for you?

= ArrayFormula(IF( ISBLANK($AE$2), 
    IF(O2:O="April 2020",                            (AJ2:AJ/60)*$AE$3, 
       IF(O2:O="May 2020",                           (AJ2:AJ/60)*$AE$4, 
          IF(O2:O="June 2020",                       (AJ2:AJ/60)*$AE$5, 
             IF(O2:O="July 2020",                    (AJ2:AJ/60)*$AE$6, 
                IF(O2:O="August 2020",               (AJ2:AJ/60)*$AE$7, 
                   IF(O2:O="September 2020",         (AJ2:AJ/60)*$AE$8,
                      IF(O2:O="October 2020",        (AJ2:AJ/60)*$AE$9,
                         IF(O2:O="November 2020",    (AJ2:AJ/60)*$AE$10,
                            IF(O2:O="December 2020", (AJ2:AJ/60)*$AE$11))))))))),
    (AJ2:AJ/60)*$AE$2))

Let us know if that does what you want...

The formula is in G2 of the added column shown below.

在此处输入图像描述

UPDATE: Since I had inserted a column, to demonstrate that this formula gave the exact same answers as your formulas in column F, the ranges were offset. Here is the same formula corrected for placement in F2.

= ArrayFormula(IF( ISBLANK($AD$2), 
    IF(N2:N="April 2020",                            (AI2:AI/60)*$AD$3, 
       IF(N2:N="May 2020",                           (AI2:AI/60)*$AD$4, 
          IF(N2:N="June 2020",                       (AI2:AI/60)*$AD$5, 
             IF(N2:N="July 2020",                    (AI2:AI/60)*$AD$6, 
                IF(N2:N="August 2020",               (AI2:AI/60)*$AD$7, 
                   IF(N2:N="September 2020",         (AI2:AI/60)*$AD$8,
                      IF(N2:N="October 2020",        (AI2:AI/60)*$AD$9,
                         IF(N2:N="November 2020",    (AI2:AI/60)*$AD$10,
                            IF(N2:N="December 2020", (AI2:AI/60)*$AD$11))))))))),
    (AI2:AI/60)*$AD$2))

UPDATE#2:

I have added a tab to your sheet, Calendar-GK. Cell F1 has the final formula, which includes the header title, and is the following now:

={"Money";ArrayFormula(IF( ISBLANK($AD$2), 
    IF(N2:N="April 2020",                            (AI2:AI/60)*$AD$3, 
       IF(N2:N="May 2020",                           (AI2:AI/60)*$AD$4, 
          IF(N2:N="June 2020",                       (AI2:AI/60)*$AD$5, 
             IF(N2:N="July 2020",                    (AI2:AI/60)*$AD$6, 
                IF(N2:N="August 2020",               (AI2:AI/60)*$AD$7, 
                   IF(N2:N="September 2020",         (AI2:AI/60)*$AD$8,
                      IF(N2:N="October 2020",        (AI2:AI/60)*$AD$9,
                         IF(N2:N="November 2020",    (AI2:AI/60)*$AD$10,
                            IF(N2:N="December 2020", (AI2:AI/60)*$AD$11))))))))),
    (AI2:AI/60)*$AD$2))}

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM