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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
harlanpost
New Member

Python script not allowing me to schedule refresh

Hi all,

 

I have a Power BI report built from a dataflow (that I don't have admin access to). Within Power Query, I have applied a script to one of the tables from this flow. I have then published it to Power BI Service.

 

I am getting the below error:

harlanpost_0-1711465942331.png

 

As such, I suspect the issue is related to my Python script. I have a couple of questions:

1) Why can I not refresh the report in Power BI Service with this script?

2) Are there any workarounds I could use to avoid this? 

 

I'll leave the Python script below in case anybody has any insights. The script works perfectly when executed in Power Query.

 

Thank you in advance for the help!

 

 

import pandas as pd
import re
from datetime import datetime

def extract_and_standardize_date(text):
    if pd.isna(text) or text.strip() == '':
        return None

    date_pattern = r'\b(0?[1-9]|[12][0-9]|3[01])[-/. ](0?[1-9]|1[012]|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(?:[-/. ](\d{2}|\d{4}))?\b'
    match = re.search(date_pattern, text, re.IGNORECASE)

    if match:
        groups = match.groups()
        day = groups[0]
        month = groups[1]
        year = groups[2] if groups[2] else str(datetime.now().year)  # Use current year if year is missing

        if month.isalpha():
            datetime_object = datetime.strptime(month, "%b")
            month = datetime_object.month

        if len(year) == 2:
            year = '20' + year

        return f"{day.zfill(2)}/{str(month).zfill(2)}/{year}"

    return None



dataset['standardized_date'] = dataset['Column_X'].apply(extract_and_standardize_date)

dataset

 

 

3 REPLIES 3
harlanpost
New Member

Thanks for the response.

 

I don't seem to have the ability to create a personal gateway. 

harlanpost_0-1711472632854.png

Could this be a result of the fact I'm using a dataflow?

You need to do things the other way round.  First install and run the personal gateway and then use it in a dataflow.

lbendlin
Super User
Super User

Python and R scripts and visuals mandate the use of a personal gateway.

Helpful resources

Announcements
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.