cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Generate Missing Data via Script

Hi, Im starting to use Power BI I came from QlikView. I want to know if in Power Desktop I can generate data via script, for example I have some uses cases.

 

1- Fill data from-to date

 

I have in my DB a entry

 

Id - From     -      To

a    1/1/2016       1/5/2016

b    1/1/2016       1/2/2016

 

 

Result wanted in Power BI:

 

Id - Date     

a    1/1/2016

a    1/2/2016 

a    1/3/2016

a    1/4/2016 

a    1/5/2016 

b    1/1/2016

b    1/2/2016

 

 

 

2- Fill the gaps between dates.

 

I have an exchange rate table

 

Date      -    Exchange Rate

1/1/2016     9,716    

1/5/2016     9,801

1/7/2016     10,01

 

Result wanted:

 

Date      -    Exchange Rate

1/1/2016     9,716    

1/2/2016     9,716

1/3/2016     9,716

1/4/2016     9,716

1/5/2016     9,801

1/6/2016     9,801

1/7/2016     10,01

 

Can some1 in first place tell me if this is posible via Script in Power BI. And if trully can be made pls tell me how and provide documentation about how to create custom loads.

 

Thx

 

2 REPLIES 2
Highlighted
Responsive Resident
Responsive Resident

Re: Generate Missing Data via Script

Instead of duplicating your data maybe you can try searching for a solution based on slowly changing dimensions. there are several ways to approach this. Here's one example in the following link

Business Intelligence Architect / Consultant
Highlighted
Power BI Team
Power BI Team

Re: Generate Missing Data via Script

For generating a table of dates, take a look at the CALENDARAUTO() DAX function. This creates a Calculated Table across all the date range in your model.

 

Then you can add a column to that table that pulls the relevant Exchange Rate for the dates that have a value.

 

You could fill in the remaining Exchange Rate values by using the a DAX calculation like this:

 

FullExchangeRate =

CALCULATE(

   LASTNONBLANK(Query1[Exchange Rate], TRUE()) ,

   CALCULATETABLE( DATESYTD(Query1[Date]) ,

                   DATESBETWEEN(Query1[Date],

                                BLANK(),

                                LASTDATE(Query1[Date])

                  ) ,

                  ALL(Query1)) ,

   ALL(Query1)

)

 

There might be a more efficient way to do that, but it'll work!

Helpful resources

Announcements
Meet the 2020 Season 2 Power BI Super Users!

Meet the 2020 Season 2 Power BI Super Users!

Find out who's part of the program this season, and welcome the new Super Users.

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Featured Data Story of The Month

Featured Data Story of The Month

All Data Stories Gallery contributions are reviewed for each month. We select a contribution and feature the community member the following month.

Power BI Dev Camp - Developing with .NET Core

Power BI Dev Camp - Developing with .NET Core

Learn how to develop custom web applications for Power BI using .NET Core 3.1 and .NET 5.

Top Solution Authors
Top Kudoed Authors