define variable

Valentin

Board Regular
Joined
Oct 29, 2010
Messages
96
Office Version
  1. 365
Platform
  1. Windows
I have the following code,

let

Source =Web.Page(Web.Contents("https://www.euro-millions.com/results/05-02-2016")),



and for the last part "02-05-2016" I want to declare a variable,
is this possible with power query and if so how I declare that variable?
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
just as example you could

Dim LottoDate

LotoDate = sheets("yoursheetname").Range("A1") ' you'll have to get the right date format at some stage

Then

Source =Web.Page(Web.Contents("https://www.euro-millions.com/results/" & LotoDate & """")), need to get the speech marks right

How thats done in Power Query I'm not sure
 
Last edited:
Upvote 0
I didn't expect it to work perfectly, just to give you a position to start from, it will need adapting to what you have already, none of which has been shared to even start to work from
 
Upvote 0
If you give the cell where your date sits the name "Variable", the following code will deliver the content:

let
Source = Excel.CurrentWorkbook(){[Name="Variable"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type date}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"Column1", type text}}),
Repl = Table.ReplaceValue(#"Changed Type1",".","-",Replacer.ReplaceText,{"Column1"}),
#"Added Custom" = Table.AddColumn(Repl, "Custom", each Web.Page(Web.Contents("https://www.euro-millions.com/results/"&[Column1])))
in
#"Added Custom"
 
Upvote 0
Hi
As a variant
Code:
    dateInCell = Excel.CurrentWorkbook(){[Name="Variable"]}[Content]{0}[Column1],
    queryDate = DateTime.ToText(dateInCell, "dd-MM-yyyy")
    source = Web.Page(Web.Contents("https://www.euro-millions.com/results/"&queryDate))
Regards,
 
Upvote 0

Forum statistics

Threads
1,226,694
Messages
6,192,473
Members
453,726
Latest member
JoeH57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top