The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Good afternoone everyone
Me (a noobie to PowerBI) would like to add a powerquery step to the following example data:
Resultaatteken | Geldig tm |
X | 25/02/2020 |
@ | null |
X | 22/10/2030 |
if the "Geldig tm" column has a date that is in the past I'd like the "Resultaatteken value to be V. as such (with the help of these forums!) I wrote the following code:
= Table.ReplaceValue(PrevStep, each [Resultaatteken] , each if DateTime.LocalNow > [Geldig tm] then "V" else [Resultaatteken],Replacer.ReplaceValue,{"Resultaatteken"})
Unfortunately this is not giving me the desired result, at which time I decided I'd like to see what the value of DateTime.LocalNow is (Suspecting it is some form of display or Date & datetime shennanigans) so I copied the Resultaatteken column to Resultaattekenz and ran:
= Table.ReplaceValue(#"Volgorde van kolommen gewijzigd1", each [Resultaattekenz], DateTime.LocalNow ,Replacer.ReplaceValue,{ "Resultaattekenz"})
which doesn't change the value at all, however when I replace DateTime.LocalNow in the second query with a string literal "Why" then it changes the values of the collumn as I expected.. So as far as I can tell DateTime.LocalNow appears empty.
Long story short(er) I was hoping to find some wisdom on this forum;
Thank you in advance for any and all help given!
Solved! Go to Solution.
Hi @JesseV ,
You can try to use DateTime.Date function.
= Table.ReplaceValue(#"Changed Type with Locale", each [Resultaatteken], DateTime.Date(DateTime.LocalNow()),Replacer.ReplaceValue,{ "Resultaatteken"})
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
So through the magic of reading the manual I have discored that I was missing as datetime after DateTime.LocalNow()
= Table.ReplaceValue(#"Volgorde van kolommen gewijzigd1", each [Resultaattekenz], DateTime.LocalNow() as datetime ,Replacer.ReplaceValue,{ "Resultaattekenz"})
Which just leaves me wondering how I can convert it to just the date value ('as date' unfortunately didn't take.. which seems a little odd to me)
Hi @JesseV ,
You can try to use DateTime.Date function.
= Table.ReplaceValue(#"Changed Type with Locale", each [Resultaatteken], DateTime.Date(DateTime.LocalNow()),Replacer.ReplaceValue,{ "Resultaatteken"})
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
10 | |
9 | |
6 | |
6 | |
5 |
User | Count |
---|---|
20 | |
15 | |
14 | |
10 | |
7 |