Forum Discussion
Beginner question - IF statement
Anonymous welcome to Power BI !!!
I am hopin that you are atleast familiar with the basic concepts of Power BI..such as Calculated COlumn, Measures..etc.
DAX measure is a very strong concept in Power BI and the rule of thumb is not to use calculated column if you can get a measure to return what you want
You can utilize the following measure to give you what you need
Measure=AVERAGEX(CROSSJOIN(VALUES('tbl1'[BRAND_NAME_NEW]),VALUES('tbl2'[WAIT_TIME_IN_QUE])),
SWITCH(TRUE(),'tbl1'[BRAND_NAME_NEW]="Lensway"&&'tbl2'[WAIT_TIME_IN_QUE] >90,0
'tbl1'[BRAND_NAME_NEW]="Lensway"&&'tbl2'[WAIT_TIME_IN_QUE] >120,0
,1))
- Anonymous4 years agoNot applicable
Hey guys, thanks so much for taking the time!
I'm trying my best to get accustomed to DAX and everything but I couldn't seem to get this to work.
I tried the functions you posted but it didn't work. One thing that I don't understand is that some of the fields won't automatically show up when typing the function. For instance, if I type IF(AND([BRAND to get "BRAND_NAME_NEW" to show up, it doesn't. Same goes for other fields, lite date. I'm trying to make a "calls per hour" graph and have tried the "HOUR" function. But when typing HOUR(ORIG for "ORIGINATED_DATE" field (which includes date and time) nothing shows up. I'll post an image to make it clear.
Hope this makes sense!- smpa014 years agoCommunity Champion
Anonymous can you post a sample data and expected output? I could return the desired obix to you
- v-janeyg-msft4 years agoCommunity Support
Hi, Anonymous
Because he uses column and you use measure, measure can only get aggregated values, so it won't display column name directly.
Do you want to calculate this average at one time? Or you also needs to show 0 and 1 in other column.
As they said, 'upload some insensitive data samples and expected output' will get accurate help.
Best Regards,
Community Support Team _ Janey- Anonymous4 years agoNot applicable
Thanks for all your help. Finally got it to work with this (BRAND_KEY) is just the numeral version of the brand names:
IF('dwh_fact f_css_data'[WAIT_TIME_IN_QUE] > 90 && 'dwh_fact f_css_data'[BRAND_KEY] = 4 ,0 , IF('dwh_fact f_css_data'[WAIT_TIME_IN_QUE] > 120 && 'dwh_fact f_css_data'[BRAND_KEY] = 14, 0, 1))And the learning continues 🙂