PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, November 3, 2022

[FIXED] How to execute the function only when there is a specific value in another column

 November 03, 2022     google-sheets, google-sheets-formula, if-statement, import, lambda     No comments   

Issue

Dear StackOverFlow users,

I would love to create a function that will do the calculation based on the specific value in another column.

enter image description here

SYMBOL NAME STOCK TYPE DIVIDEND
AAL American Airlines Group Inc Growth Do this "(SUBSTITUTE(IMPORTXML(CONCATENATE("https://finviz.com/quote.ashx?t=";r);'XML IMPORT'!C$3);".";",")/4)" only if C:C="Dividend" else "-"
T AT&T Inc. Dividend Do this "(SUBSTITUTE(IMPORTXML(CONCATENATE("https://finviz.com/quote.ashx?t=";r);'XML IMPORT'!C$3);".";",")/4)" only if C:C="Dividend" else "-"

Example xls is here:

https://docs.google.com/spreadsheets/d/1y6d0_0x_8aooy9iYfc9HtspwBpN6k5mJV5TKeOsnjcQ/edit?usp=sharing


Solution

use IF:

=IF(C3="Dividend"; SUBSTITUTE(
 IMPORTXML("https://finviz.com/quote.ashx?t="&A3; 'XML IMPORT'!C$3); "."; ",")/4; "-")

array would be:

={"DIVIDEND";INDEX(MAP(C2:C; A2:A; LAMBDA(c; a; IF(c="Dividend"; SUBSTITUTE(
 IMPORTXML("https://finviz.com/quote.ashx?t="&a; 'XML IMPORT'!C$3); "."; ",")/4; "-"))))}


Answered By - player0
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing