Azure Series: Control Power BI Report Viewing in Power Apps Using a Time Window

We’ve created a step-by-step walkthrough video that demonstrates the entire setup in real-time.
πŸ‘‰ Watch it on YouTube – JBSWiki Channel

Controlling Power BI report access based on time is an essential feature for organizations with time-bound reporting requirements, compliance restrictions, or business-specific policies. In this blog post, we will walk through a real-world use case where we use Power Apps to embed a Power BI report and restrict its access based on a specific time window (9:00 AM to 1:00 PM).

This solution is simple, clean, and effectiveβ€”and uses only native capabilities in Power Apps, without needing advanced permissions or complex security configurations.

Let’s dive in!


βœ… Why Time-Based Access?

There are several scenarios where restricting Power BI report access by time makes sense:

  • πŸ“… Business Hours Only Access: You want employees to view reports only during operational hours.
  • πŸ” Security Compliance: You need to control access windows for sensitive reports.
  • πŸ“Š Scheduled Refresh Windows: Prevent access during report refresh to avoid outdated data usage.

Rather than configuring complex access rules at the Power BI service level, Power Apps gives you flexibility to embed the report conditionally, based on the system time and logic defined in your app.


🧰 What You’ll Need

  • Microsoft Power Apps license
  • A published Power BI report
  • The iFrame URL of the Power BI report (embed link)
  • Basic familiarity with Power FX, HTML Text Control, and variables in Power Apps

πŸ”§ Step-by-Step Implementation

1. 🎯 Define the Time-Based Logic

We’ll use a button in Power Apps that sets the current time into variables and checks if the time falls between 9:00 AM and 1:00 PM. If yes, it launches the Power BI report; otherwise, it shows an Access Denied notification.

πŸ”Ή Code for the Button in Power Apps:

Set(varNow, Now());
Set(varHour, Hour(varNow));
Set(varMinute, Minute(varNow));
Set(varCurrentTime, Time(varHour, varMinute, 0));
Set(varAccessAllowed, varCurrentTime >= Time(9, 0, 0) && varCurrentTime < Time(13, 0, 0));
If(
    varAccessAllowed,
    Launch("https://app.powerbi.com/reportEmbed?reportId=fc00e03c-ec12-4038-af5a-2bfb9972f70b&autoAuth=true"),
    Notify("Access denied. You are allowed to view this report between 9:00 - 13:00.", NotificationType.Error)
)

πŸ’‘ Explanation:

  • varNow: Captures the current system timestamp.
  • varHour & varMinute: Extracts the hour and minute.
  • varCurrentTime: Combines hour and minute into a Time object.
  • varAccessAllowed: Boolean flag based on whether the current time is between 9:00 AM and 1:00 PM.
  • If(...): Launches the Power BI report if access is allowed; otherwise, shows an error notification.

2. πŸ“‹ Display Time and Access Status

Add a Text Label to show the current time and whether access is allowed. This helps with testing and gives users clarity.

πŸ”Ή Code for the Text Label:

"Now: " & Text(Now(), "[$-en-US]HH:mm:ss") & 
" | Allowed: " & Text(varAccessAllowed)

This will dynamically update and display:

  • Current time
  • Whether access is currently allowed

Example output:
Now: 10:45:23 | Allowed: true

🌐 Real-World Use Cases

Here are a few scenarios where this logic is useful:

ScenarioBenefit
πŸ“ˆ Internal DashboardsRestrict to working hours only
🏦 Banking/Finance AppsLimit sensitive data views during authorized hours
🧾 Compliance & AuditsEnforce strict access rules using app logic
🏒 Client-Specific ReportsTailor access hours based on agreements

πŸš€ Why Use Power Apps for This?

βœ… Flexible Control: No need to alter Power BI permissions
βœ… Low-Code Friendly: Easy to maintain and update
βœ… Secure Embedding: iFrame loads only after validation
βœ… User Feedback: Display live status and messages using simple UI elements


πŸ“Œ Tips and Best Practices

  • πŸ• Always use 24-hour format when working with Time() in Power FX
  • πŸ”’ Do not expose sensitive logic in client-side apps unless supported by security measures
  • πŸ” Consider refreshing the time variables periodically if embedding directly in app screens
  • πŸ–ΌοΈ Use a Gallery or Container if embedding multiple reports with different rules

πŸŽ₯ Watch the Video

We’ve created a step-by-step walkthrough video that demonstrates the entire setup in real-time.
πŸ‘‰ Watch it on YouTube – JBSWiki Channel


🏁 Conclusion

Using Power Apps + Power BI, you can securely control report visibility based on custom business logic. This time-based control pattern is just one of many ways to extend app capabilities using simple Power FX expressions.

With this setup:

  • Your users see reports only when they’re supposed to
  • Your data remains protected
  • Your app feels responsive and intelligent

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided β€œAS IS” with no warranties, and confers no rights.

Power BI – The key didn’t match any rows in the table

-> I was working on an existing Power BI desktop file and was utilizing a different SQL Server database than the one on which this Power BI file was created.

-> During the initial load I got below error,

The key didn’t match any rows in the table.

-> With this error, I clicked on “Transform Data” and check for this particular object,

Expression.Error: The key didn’t match any rows in the table.
Details:
Key=
Schema=dbo
Item=tbl_DisabledIndexes
Table=[Table]

-> I happened to check if the object dbo.Tbl_DisabledIndexes was present in the underlying database,

-> It seems like the object dbo.Tbl_DisabledIndexes is not present on the database. This Power BI Report when created based on a different database should have contained this table, but the current database doesn’t have it.

-> I corrected that by creating the table dbo.Tbl_DisabledIndexes and populated the appropriate rows into that SQL Server table.

-> Once the table was available, I reloaded the report and it worked as expected this time.

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided β€œAS IS” with no warranties, and confers no rights.

Power BI – Value should be a Currency

-> I was trying to create a new conditional column called “Price Tier” in Power BI based on a Currency column called Price. I got below message,

Value should be a Currency.

-> I couldn’t get much from the internet for this issue.

-> I ended up changing the currency column “Price” to decimal and then created the new conditional column “Price Tier”.

-> Once the new Conditional Column “Price Tier” was created. I changed “Price” back to Currency from Decimal.

-> Not sure if this is a bug, but the workaround actually worked for me.

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided β€œAS IS” with no warranties, and confers no rights.