How to apply or use IF function using Calculated Field in Looker | Use IF Function in Looker

Опубликовано: 12 Февраль 2026
на канале: The Data Millennials
2,180
11

If we need to calculate the profit from the unit price but we need to classify the category first , so we have to give the profit percentage based condition like
For category-1 ,2,3 -profit is 10% and for all rest category the profit percentage is 25%

So for such cases we can use IF function

So in this video we will create this a table and then we are going to apply or use the IF function as a calculated field in our charts or tables from scratch so that you can get the awareness that when where and how we can apply the IF function using calculated field,

And before we use this function, let's understand the IF function first.

IF function is a conditional function in looker and it Return 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.


Now lets go and create a calculated field using IF function in our table
– process–


IF 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.


IF (Category IN ( "Category-1", "Category-2" , "Category-3") , UNIT Price*.10 ,UNIT Price*.25 )


You can follow us on the below social media handles:-
Youtube: -    / @thedatamillennials  
Facebook:-   / the-data-millennials-596575371027542  
Instagram: -   / the_data_millennials  
LinkedIn: -   / data-millennials-6b5a031b3  
Twitter: -   / datamillennials  

If you want to be become an Data Analyst or BuCASEess Analyst who has a great analytical Skill then you can follow the below links
Excel Playlist:-https://bit.ly/3rd9cEH
SQL Playlist:- https://bit.ly/3v28GKY
Google Data Studio playlist:- https://bit.ly/3v7czyc