Forum Discussion

callum8004's avatar
callum8004
Regular Visitor
4 years ago
Solved

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 IDPostal ApplicationOnline ApplicationApplication
00119/2/2022  
002 14/7/2022 
003   
00412/7/202216/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

     

     

     





          

    Showcase Report – Contoso By SpartaBI

3 Replies

  • You can add a calculated column like

    Application =
    SWITCH (
        TRUE (),
        NOT ISBLANK ( 'Table'[Postal] ), "Postal",
        NOT ISBLANK ( 'Table'[Online] ), "Online",
        "No Application"
    )
  • Anonymous's avatar
    Anonymous
    Not 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.

     

  • SpartaBI's avatar
    SpartaBI
    Community 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

     

     

     





          

    Showcase Report – Contoso By SpartaBI