Forum Discussion
Calculated column based on two date columns
Hi
First post and brand new to Power BI.
I have a table that has two columns that contain dates as followls
| Customer ID | Postal Application | Online Application | Application |
| 001 | 19/2/2022 | ||
| 002 | 14/7/2022 | ||
| 003 | |||
| 004 | 12/7/2022 | 16/7/2022 |
GOAL: I need the Application Column to state either "Postal", "Online" "No Application" based on col2 and col3 of this table. The part which I'm finding hard here is that I cannot do this in Power Query as col2&3 come from other tables via the related() function and I also need col4 to still use "Postal" if there is a date in both columns. Ive tried nestedIFs but just spent hours going round and round - anyone shed any light on how to achieve this?
callum8004 write this calculated column:
Application = VAR _postal = 'Table'[Postal Application] VAR _online = 'Table'[Online Application] VAR _result = SWITCH( TRUE(), _postal <> BLANK() && _online <> BLANK(), "Both", _postal <> BLANK(), "Postal", _online <> BLANK(), "Online", "No Application" ) RETURN _result
3 Replies
- johnt75Super User
You can add a calculated column like
Application = SWITCH ( TRUE (), NOT ISBLANK ( 'Table'[Postal] ), "Postal", NOT ISBLANK ( 'Table'[Online] ), "Online", "No Application" ) - AnonymousNot applicable
callum8004 if you have both col2 and col3 in the same table now, you can directly use switch case column using DAX Switch function.
If you want it to be in power query, then use MERGE QURIES option with left outer join and get only col3 then using conditional column you can create this.
let me know if that helps.
- SpartaBICommunity Champion
callum8004 write this calculated column:
Application = VAR _postal = 'Table'[Postal Application] VAR _online = 'Table'[Online Application] VAR _result = SWITCH( TRUE(), _postal <> BLANK() && _online <> BLANK(), "Both", _postal <> BLANK(), "Postal", _online <> BLANK(), "Online", "No Application" ) RETURN _result