| |

Dates in Power BI

In my last post, I wrote about using the “programming aspect” of Power BI to bring in unemployment numbers for 50 states rather than I manually importing and then merging them. And I talked about using AI to do that “programming”.

During that exercise, I actually learned some new stuff, although I don’t think I mentioned it. The big thing that I learned was that the URL did not have to be such a long string that I copied from the site. There was actually a more concise version that I could use.

In this post, I’m going to write about dates, something that has always been problematic for me, whether in Excel or Power BI.

The Main Layout

For the images below, all data are being imported from the FRED site. The citation is:

U.S. Bureau of Labor Statistics, Unemployment Rate in “State” [STUR], retrieved from FRED, Federal Reserve Bank of St. Louis; https://fred.stlouisfed.org/series/STUR, March 29, 2026.

Where “ST” is the state’s alpha abbreviation. So for Nevada, it would be NV.

Image 1: Main Layout

Image 1 shows one of the tabs in my Power BI file. That’s the basic layout of this page. Upper left hand corner shows the slicers for the states which is on Nevada. In case I haven’t made it clear, image 2 shows the orange arrow pointing to the state slicers.

Image 2: Orange arrow pointing to state slicers

Off to the right is a line chart depicting the unemployment levels over time for Nevada.

The lower left are 2 tables (see image 3 below) which I’m using to double check the numbers. Sometimes the numbers don’t come through as you expected and I often use tables, whether in Power BI or in Excel, to verify that I have set up things properly. This is really useful for when I create calculated measures.

Image 3: Orange arrows pointing to tables

And then finally, the lower right corner is a series of dates (see image 4).

Image 4: The dates

The dates in Power BI

Let’s drill down on those dates I’m pulling so you understand what it is I’m retrieving.

First of all, you often want to know what the latest date was you can retrieve, especially if the supplier of the data does not update in real time. In this instance, I’m seeing the government did not provide data for February even though I’m retrieving the data in late March. The government is kind of lagging.

The “latest date” represents the last time period the government is supplying the data. For this particular U3 unemployment data, the government supplied only up through January 2026.

The “YoY date” is just the one year ago date from the latest date, so in this case, the YoY date is January 2025.

“Updated date” is the date that the government has said it updated its data. April 9, 2026 was the last time the government updated its site.

And finally, “new release date” is the government stated date for when the data will be updated, so the government was announcing that the next update would be April 22, 2026. Spoiler alert: it didn’t.

Calculated measures

I wanted to use cards to present unemployment numbers for the “latest date” and the prior year date (“YoY date” but I found out that the cards have changed. Here’s where CoPilot came in because I wanted to find out how to use a card feature that pulled up the last date.

Alas, the card no longer had that feature and CoPilot suggested creating a measure. In Power BI you can create “New Measure” which are formulas or mini-programs.

Here are the calculations you can use to create measures for the “latest date” and for “YoY date”:

Latest Date = MAX(‘U3 State Unemployment Seasonally Adjusted'[observation_date])

YoY Date = EDATE(‘U3 State Unemployment Seasonally Adjusted'[Latest Date],-12)

Note: “U3 State Unemployment Seasonally Adjusted” is the query/table pulling in the U3 date from FRED. [observation_date] is the date field coming in with the import.

The “latest date” is using the MAX function and “YoY Date” is using the EDATE function.

Both “latest date” and “YoY date” are actually calculated from the dates imported from FRED so measures can be created.

The “updated date” or “new release date” did not come in through the import nor can they be calculated from the dates that did get imported.

Another method had to be deployed.

Scraping dates from the web

Based upon that header, yes, Power BI appears to be able to scrape web data.

Here’s the actual program to put in the Advanced Editor, courtesy of CoPilot:

let
   Source = Web.Contents("https://fred.stlouisfed.org/series/TXUR"),
   Raw = Text.FromBinary(Source),

   // Extract Updated Date (clean span)
   UpdatedDateText =
       Text.BetweenDelimiters(
           Raw,
           "series-meta-updated-date"">",
           "</span>"
       ),

   // --- Next Release Date ---

   // 1. Find the position of the span that holds the next release date
   NextReleaseSpanPos =
       Text.PositionOf(
           Raw,
           "series-meta-updated-date text-link"
       ),

   // 2. Take the substring starting at that span
   NextReleaseChunk =
       Text.Middle(
           Raw,
           NextReleaseSpanPos
       ),

   // 3. Now just grab what's between ">" and "</span>" in that chunk
   NextReleaseDateText =
       Text.BetweenDelimiters(
           NextReleaseChunk,
           ">",
           "</span>"
       ),

   // Convert both to dates
   UpdatedDate = Date.FromText(Text.Trim(UpdatedDateText)),
   NextReleaseDate = Date.FromText(Text.Trim(NextReleaseDateText))

in
    #table(
        {"UpdatedDate", "NextReleaseDate"},
        {{UpdatedDate, NextReleaseDate}}
    )

I am going to also paste in a jpeg/image of how the code looks in my Power BI Advanced Editor so you can see the spacing aligned:

The updated date was a very clean scraping from the HTML that you can find on the web. When you are out on the web at a site and you right click the page and then select developers’ tool (or something similar), you will get a panel showing the HTML code for how the page is laid out.

Power BI is just trying to find the HTML line that adds in the “updated date” and “new release date” and extract the data from there. Unfortunately, the “new release date” was not so clean and I had to do multiple tries with CoPilot to get something working.

By the way, I learned something new: // is how you can enter your comments into the program. There is a set of comments in the image that I left out when I provided the code. That comment section was one of the failed efforts to scrape “new release date”.

Final comments on dates

So, with a combination of calculated measures and web scraping, I was able to get 4 different kinds of dates to inform my users how old or recent the data is, and when the new release will be offered. Those are often important information when looking at data or visualizations. Dates can often be a good way of determining how good (recent) the data is.

But I will say, they are often difficult to gather in Power BI. CoPilot actually helped out, cutting potentially days or weeks into hours or minutes.

Similar Posts