Forum Discussion

blytonpereira's avatar
blytonpereira
Helper II
7 years ago
Solved

Appending a created table + IF statement in PowerQuery

Hi I need to write an IF statement for one column vs a single value. The Key value will alwyas be only one value.

 

Key Value

12

 

Column 1   Column 2

X                    IF (Key Value) < a then "b" else "c"

Y                    IF (Key Value) < a then "b" else "c"

Z                     IF (Key Value) < a then "b" else "c"

 

I have shared my simple powerBI file here

 

The step is named  in PowerQuery as "Vlookup vs Fin MonthNo". This is the single value.

Next I need to insert a step with the IF statemenr IF (Vlookup vs Fin MonthNo) < Month.Date(CurrentDate) then "xx" else "yy". This field needs to run for the whole calendar table, so this should be a new column in the FULL table, not only on the single row level.

 

Also for some reason my date format in the Calendar is correct, but it is not creating a hierarchy and I am not sure why. It is a Financial Calendar 445 that I am using.

Thank you.

Blyton

  • ImkeF's avatar
    ImkeF
    7 years ago

    No need to transform your single value to a column, instead just reference it directly like so:

     

    Table.AddColumn(#"Fin MonthOffset", "Custom", each if #"Vlookup to Fin MonthNo"=[Fin MonthNo] then "xx" else "xy")

4 Replies