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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Join data based on date

Hello all,
Here is the output table that i want to make: 

haniya_azzahra_0-1616380639677.png

end stock = stock + production

based on tgl/date

if date <=today then  stock = stock,
if date > today then  stock = end stock 

*today is 22-03-2021
so date >=22-03-2021 is future date or > today

 

Any idea how to implement this in power query ?
or in SQL

highly appreciated for your feedback and help!
Thank You,
Regards
Haniya

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

Your description about expected output is not very clear. What does your original data look like? Which columns and data are original data and which are expected data?

If you want Today to be changed dynamically when executing the expression, you may add a custom column

if [TGL] <= Date.From(DateTime.LocalNow()) then [Stock] else [EndStock]

 

Regards,
Community Support Team _ Jing

Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

not 100% clear what you exactly need. But in this example I can show you how to add a new column that based on todays date is changing the calculation.

This is the formula

if [Date]<= Date.From(DateTime.FixedLocalNow()) then [Stock] else [Stock]+[Production]

here the complete example

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TcixDQAwCAOwX5gRgsA3iP/faJsuDF7cLQjzNDhCVL7R21gNYufqJHaxXxbNHA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Stock = _t, Production = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Stock", Int64.Type}, {"Production", Int64.Type}}, "de-DE"),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "endstock", each if [Date]<= Date.From(DateTime.FixedLocalNow()) then [Stock] else [Stock]+[Production])
in
    #"Added Custom"

and this is the output

Jimmy801_0-1616400703272.png

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors