Forum Discussion

JonV's avatar
JonV
Helper II
7 years ago
Solved

How to populate missing rows dynamically for calculations?

I'm trying to create a table in Power BI that, at its core, displayed the frequency with which certain items are purchased. This data is being pulled from MS SQL and looks something like this:

 

 

From there, various calculations will be applied to each row. My trouble is that those calculations (measures) still need to run on the rows where the frequency of a given quantity was 0. Thus, what I figure I'm needing to do is add rows with a frequency of 0 for all quantities from 1 to the max value for each item.

 

My immediate thought is that this is much like completing a table with dates by joining to a date table. While I suspect this is the right approach, I'm running into 2 issues:

 

  1. The max frequency is not consistent. For some widgets it might be 7. For others it might be 5,000. So I generate a quantity table with a max of 5,000. Thus, when creating a table of values to join on and telling PBI to show items with no data, it displays 5,000 rows. I need it to truncate at the max value for the widget selected.
  2. It doesn't actually perform calculations. Even though it shows the rows, there's no data in them to calculate with.

So is there any way I can get the filtered table to include the omitted rows up to the max and populate it with 0's so the calculations will run?

7 Replies