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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.