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.

Leave a Reply