Notification

This article is about Looker Studio. For Looker documentation, visit https://cloud.google.com/looker/docs/intro.

Požadovaná stránka aktuálně není k dispozici ve vašem jazyce. V dolní části stránky však můžete vybrat jiný jazyk, případně pomocí funkce překladu integrované v prohlížeči Google Chrome jakoukoli stránku okamžitě přeložit do vybraného jazyka.

IF

Returns a value based on a conditional expression.

IF defines a condition and returns a result when that condition is met, or returns a different result if that condition is not met.

Note: IF is similar to CASE but acts only on a single condition, and returns only one possible true result and one possible false result.

Sample usage

Calculate a bonus rate if actual sales exceed forecast sales:

IF(Actual > Forecast, Bonus *1.2, Bonus)

Syntax

IF(condition, true_result, false_result)

Parameters

  • condition - The expression to evaluate. condition can be any valid Boolean expression.
  • true_result - the value to return if condition is true. true_result can be any valid expression.
  • false_result - the value to return if condition is false. false_result can be any valid expression.

Examples

Return a dimension based on a parameter selection.

For example, you can create a Boolean parameter, Forecast Parameter, and use it to return a column of forecasted data. Otherwise, use the actual data:

IF(Forecast Parameter, Forecast Data, Actual Data)

Identify records that are older than a certain number of days before today:

IF(DATETIME_DIFF(TODAY(), Date, DAY) > 60, "old","new")

A more complex condition with logical AND, and regular expression matching:

IF(Event name = "purchase" AND (REGEXP_MATCH(Page path, ".*footwear.*") OR REGEXP_MATCH(Page path, ".*shoes.*")), "Shoe Sales", Page title)
While you can test for multiple conditions using AND and OR, as shown above, if you need more than 2 possible results, use CASE or simple CASE.

Pomohly vám tyto informace?

Jak bychom článek mohli vylepšit?
true
What's new in Looker Studio?

Learn about new features and recent changes. Looker Studio release notes live on Google Cloud.

Search
Clear search
Close search
Main menu
16978055804893726296
true
Prohledat Centrum nápovědy
true
true
true
true
true
102097
false
false