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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
ivorhooper
New Member

Relative Date in Query Parameter

Hi All,

 

im not sure of the correct terms to describe what i am doing, but here goes...

 

In Power BI desktop, I am connecting to a SAP Business Warehouse query as my input data. (SapBusinessWarehouse.Cubes).

When I'm adding items into the query, I enter a "key date" as a parameter. How do i make it so that this date is relative to today?

basically, i want this date to be "today -1", ie yesterday's date.

I have a schedule refresh on this query, so it updates every day. However, this is no good to me as every day i have to go into the query and change the "key date" to yesterday's date.

 

In the advanced editor in the query, the line looks like this:

 

{Cube.ApplyParameter, "[!V000001]", {"20191001"}}

 

thanks

Ivor.

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @ivorhooper 

 

You can create a blank query with the code below, the name of the query "YesterdayAsString".

let
    yesterday = 
        Date.AddDays( 
            DateTime.Date( 
                DateTime.LocalNow() ), -1 
        ),
    year = Date.Year( yesterday ) * 10000,
    month = Date.Month( yesterday ) * 100,
    day = Date.Day( yesterday ),
    textDate = Text.From( year + month + day ) 
in
    textDate

Next, adjust your m Expression to 

= {Cube.ApplyParameter, "[!V000001]", { YesterdayAsString }}

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski



View solution in original post

4 REPLIES 4
Mariusz
Community Champion
Community Champion

Hi @ivorhooper 

 

You can create a blank query with the code below, the name of the query "YesterdayAsString".

let
    yesterday = 
        Date.AddDays( 
            DateTime.Date( 
                DateTime.LocalNow() ), -1 
        ),
    year = Date.Year( yesterday ) * 10000,
    month = Date.Month( yesterday ) * 100,
    day = Date.Day( yesterday ),
    textDate = Text.From( year + month + day ) 
in
    textDate

Next, adjust your m Expression to 

= {Cube.ApplyParameter, "[!V000001]", { YesterdayAsString }}

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski



Genious, thanks for sharing!

Thanks @Mariusz , this works very well!

Anonymous
Not applicable

Hi,

 

I am trying to do a similar thing, but using SAP HANA as a data source. I tried a few diferent syntax, but it does not work, any ideas?

The code with the value hardcoded looks like below

 

'PLACEHOLDER' = ('$$keydate$$',#(lf) #(tab) '20180903'

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors