Forum Discussion

paw1's avatar
paw1
Icon for Helper I rankHelper I
3 years ago
Solved

If logic help in Power BI

Hi,

 

I have below if logic in Tableau could you please help me to convert the same in Power BI.

 

if YEAR([Deal Date Active])>0 then [Deal Date Active]
elseif max(ifnull(year([Deal Date Monitored]),0),ifnull(YEAR([Deal Createddate]),0))=2020 then
if YEAR([Deal Date Priority])=2020 then DATEPARSE("yyyy-mm-dd","2020-01-01")
elseif year([Deal Date High Priority])=2020 then DATEPARSE("yyyy-mm-dd","2020-01-01")
elseif year([Deal Date Signed])=2020 then DATEPARSE("yyyy-mm-dd","2020-01-01")
elseif year([Deal Date Closed])=2020 then DATEPARSE("yyyy-mm-dd","2020-01-01")
else dateparse("yyyy-mm-dd",str(max(ifnull(year([Deal Date Monitored]),0),ifnull(YEAR([Deal Createddate]),0)))+"-01-01")
END

Thanks in advance

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi paw1 ,

     

    Please try this calculated column.

    Column=
    IF(
        YEAR([Deal Date Active]) > 0,
        [Deal Date Active],
        IF(
            MAX(
                IF(
                    ISBLANK([Deal Date Monitored].YEAR),
                    0,
                    [Deal Date Monitored].YEAR
                ),
                IF(
                    ISBLANK([Deal Createddate].YEAR),
                    0,
                    [Deal Createddate].YEAR
                )
            ) = 2020,
            SWITCH(
                TRUE(),
                YEAR([Deal Date Priority]) = 2020, DATE(2020, 1, 1),
                YEAR([Deal Date High Priority]) = 2020, DATE(2020, 1, 1),
                YEAR([Deal Date Signed]) = 2020, DATE(2020, 1, 1),
                YEAR([Deal Date Closed]) = 2020, DATE(2020, 1, 1),
                DATE(YEAR(MAX(
                    IF(
                        ISBLANK([Deal Date Monitored].YEAR),
                        0,
                        [Deal Date Monitored].YEAR
                    ),
                    IF(
                        ISBLANK([Deal Createddate].YEAR),
                        0,
                        [Deal Createddate].YEAR
                    )
                )), 1, 1)
            ),
            BLANK()
        )
    )

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi paw1 ,

     

    Please try this calculated column.

    Column=
    IF(
        YEAR([Deal Date Active]) > 0,
        [Deal Date Active],
        IF(
            MAX(
                IF(
                    ISBLANK([Deal Date Monitored].YEAR),
                    0,
                    [Deal Date Monitored].YEAR
                ),
                IF(
                    ISBLANK([Deal Createddate].YEAR),
                    0,
                    [Deal Createddate].YEAR
                )
            ) = 2020,
            SWITCH(
                TRUE(),
                YEAR([Deal Date Priority]) = 2020, DATE(2020, 1, 1),
                YEAR([Deal Date High Priority]) = 2020, DATE(2020, 1, 1),
                YEAR([Deal Date Signed]) = 2020, DATE(2020, 1, 1),
                YEAR([Deal Date Closed]) = 2020, DATE(2020, 1, 1),
                DATE(YEAR(MAX(
                    IF(
                        ISBLANK([Deal Date Monitored].YEAR),
                        0,
                        [Deal Date Monitored].YEAR
                    ),
                    IF(
                        ISBLANK([Deal Createddate].YEAR),
                        0,
                        [Deal Createddate].YEAR
                    )
                )), 1, 1)
            ),
            BLANK()
        )
    )

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly.