Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Create rows for missing weekly data

Hello,

 

A while back, I had a question regarding day of week and time data (app availability). I have since transformed this data using a coworker's SQL script, but have now run into a new issue.

 

The script I am using takes data from an enterprise data warehouse which expresses the time an app is online on a given day(s) of the week and expresses it in a format that splits it out by day of the week. For instance, this:

App NameApp CodeStart DayStart TimeEnd DayEnd Time
Generic11111Mon9:00:00 AMFri5:00:00 PM

 

becomes this:

App NameApp CodeDayStart TimeEnd Time
Generic11111Mon9:00:00 AM11:59:59 PM
Generic11111Tue12:00:00 AM11:59:59 PM
Generic11111Wed12:00:00 AM11:59:59 PM
Generic11111Thu12:00:00 AM11:59:59 PM
Generic11111Fri12:00:00 AM5:00:00 PM

 

The problem here is that the data warehouse does not list days in which an app is not online, and the script has no logic built into it to account for this - it would not create rows for Sunday or Saturday. This leads to gaps when attempting to visualize data, in particular with time series.

Is there a query I could run that would create the missing rows, or would this need to be created manually somehow? Thank you in advance for any assistance.

4 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      This is indeed the end result I'm looking for, but I'm running into a problem following the steps laid out in your sample PBIX file. When attempting to join the warehouse data to the final table (using the warehouse data in place of your sample data), I get all null values in the merged columns and I am not sure what I am doing wrong. I've made sure to match the merged data types to what's in the warehouse data, including with the merge key on both tables. Is there something else I'm missing?

      • hnguy71's avatar
        hnguy71
        Icon for Super User rankSuper User

        Hi Anonymous,

         

        The unique identifier might not be strong enough and thus returning black results? Try to go the other way around by changing the sample data with a few of your real data and see if you get the right results. 

  • Hi,

    If you had a Date column in your dataset, this would have been a simple one to solve.  Do you have a Date column?