Forum Discussion
Power BI IF Statement
=if (SALES_CODE='W',PART_NBR, 'ACCS')
How would this QlikView calculation be in Power BI? I have tried but it did not seem right.
5 Replies
- edhansCommunity Champion
Is this a measure or a calcluated column? If the latter (which I recommend against) it is:
=if ([SALES_CODE]='W',[PART_NBR], [ACCS])If the former, we will need more context as to what is happening. Some sample data would be good.
If you want a column of this and need to do it in Power Query, which I highly recommend, then:
=if [SALES_CODE]='W' then [PART_NBR] else [ACCS]In general, try to avoid calculated columns. There are times to use them, but it is rare. Getting data out of the source system, creating columns in Power Query, or DAX Measures are usually preferred to calculated columns. See these references:
Calculated Columns vs Measures in DAX
Calculated Columns and Measures in DAX
Storage differences between calculated columns and calculated tables
Creating a Dynamic Date Table in Power QueryHow to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum- AnonymousNot applicable
Thank you for the update.
So in QlikView this is a caculated dimension, so I was trrying to replicate this in Power BI.
Thank you, and I will try the latter calculation!
Thanks,
Chin_IT- edhansCommunity Champion
Glad to help Anonymous
Please mark one of these posts as the solutoin if it worked for you so the thread can be marked solved and others can find it, or post back with further questions if you need more help making it work.
- ryan_mayuSuper User
Anonymous
Are you creating a column or a measure? Please provide some sample data.
- AnonymousNot applicable
HI Anonymous,
Where did this data field host? In the current table or related tables? Can you please share some dummy data to help us clarify your scenario and test to coding formula?
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng