I am not entirely sure this is possible but I have a Python script which generates a dataframe based on contents in a .docx file. The basic structure of my script is as follows:
def extract_findings(filename):
...
filename = ""
findings_df = extract_findings(filename)
findings_df
I have another table loaded into Power BI called "reviews". A column in this table called "attachment" contains a path to a .docx file. Is there a way to get the latest row in the "reviews" table and extract the value at the "attachment" column and dynamically use this for my filename variable rather than hard-coding it in?
Found a solution by going to "Transform Data" and changing the "Source" code to dynamically get the last value in reviews.
= Python.Execute("#(lf)def extract_findings(filename):#(lf)
...
#(lf)filename = "&"""" &Record.Field(Table.FirstN(Table.Sort(reviews,
{{"createdon", Order.Descending}}), 1){0}, "attachment")& """"&"#(lf)
findings_df = extract_findings(filename)#(lf)
findings_df"
)