Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
blytonpereira
Helper II
Helper II

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

1 ACCEPTED SOLUTION

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")

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

4 REPLIES 4
v-lili6-msft
Community Support
Community Support

hi, @blytonpereira

It seems that there is something wrong with your file link, please post it again.

and share some expected output in multiple scenarios.

 

Best Regards,

Lin

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

Hi

 

Pls find the link of the shared calendar file below

https://drive.google.com/open?id=1__wL6fxuhqW65mmCJ5LyiFf5yTlTo925

 

I would like to compare the step "Vlookup to Fin MontNo]" to the step "Fin MonthNo", however, when I do this I get an error with the IF statement. This is because the "Vlookup to Fin MonthNo" is a single value rather than a column of values or a field.

 

What I want to achieve: So I think first we need to convert this single value to a column, basically just duplicating the value into each row of a new column. Then this would be a field and can be compared to the Fin MonthNo.

 

The images of the error can be seen below

https://drive.google.com/open?id=1AUogaMWkPYYeTVNS5rJLfY-YP71u8-3u

https://drive.google.com/open?id=1nyOW2cyy0K7YSTOqMvEmEOBuiSGs6Zht

https://drive.google.com/open?id=1AKsTNlsAQEmFaBRtWXVlfkrVU3J1obEm

 

 

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")

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

@ImkeFThank you. Worked perfectly

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.