Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
adj87
Helper I
Helper I

Adding Rows and Filling in Missing Values

I am creating a compensation dashboard and running into a snag. For many of our employees, their fixed salary doesn't change since they are primarily commissioned.

 

RowIDEmployee IDEff DateSalary
1112/22/201850000
2112/21/201951500
3112/20/202053045
4212/21/201860000
5212/27/202061800
6312/22/201850000
7312/22/201951500
8312/27/202053045
9412/29/201880000
10512/29/201880000

 

Realistically, the data would look like this, since Employee 2 was paid 60k in 2020 (I will add a YTD and account for midyear changes as well, but one hurdle at a time).

 

adj87_0-1639757460807.png

 

From what I can tell, the only way to do this might be to create a static "population" table and use that to fill in the missing dates/salaries but I was really hoping to avoid that. Is there anyway this could be done dynamically?

 

Thanks!

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @adj87 ;

You could create a date table, then create a measure.

1.create a date table.

date = GENERATE(VALUES(Pay[Eff Date].[Year]),VALUES(Pay[Employee ID]))

2.create a measure.

Measure = 
var _sum=CALCULATE(SUM('Pay'[Salary]),FILTER(ALL('Pay'),[Eff Date].[Year]=MAX('date'[Year])&&[Employee ID]=MAX('date'[Employee ID])))
var _max=CALCULATE(MAX('Pay'[Eff Date].[Year]),FILTER(ALL('Pay'),[Eff Date].[Year]<MAX('date'[Year])&&[Employee ID]=MAX('date'[Employee ID])))
return IF(_sum=BLANK(),CALCULATE(SUM([Salary]),FILTER(ALL('Pay'),[Eff Date].[Year]= _max&&[Employee ID]=MAX('date'[Employee ID]))),_sum)

The final output is shown below:

vyalanwumsft_0-1640050897649.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
v-yalanwu-msft
Community Support
Community Support

Hi, @adj87 ;

You could create a date table, then create a measure.

1.create a date table.

date = GENERATE(VALUES(Pay[Eff Date].[Year]),VALUES(Pay[Employee ID]))

2.create a measure.

Measure = 
var _sum=CALCULATE(SUM('Pay'[Salary]),FILTER(ALL('Pay'),[Eff Date].[Year]=MAX('date'[Year])&&[Employee ID]=MAX('date'[Employee ID])))
var _max=CALCULATE(MAX('Pay'[Eff Date].[Year]),FILTER(ALL('Pay'),[Eff Date].[Year]<MAX('date'[Year])&&[Employee ID]=MAX('date'[Employee ID])))
return IF(_sum=BLANK(),CALCULATE(SUM([Salary]),FILTER(ALL('Pay'),[Eff Date].[Year]= _max&&[Employee ID]=MAX('date'[Employee ID]))),_sum)

The final output is shown below:

vyalanwumsft_0-1640050897649.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks, this is a great start. I was able to apply this to my model and confirmed it works on the individual level. I do need this to both show individual and rolled up salary (Year/Regional).

 

adj87_0-1640104408272.png

 

I tried creating a seperate sum to for the individuals, but that just added up 29,120 again. I am also seeing a repeated pattern in the polulation for each year: there is a distinct count for the created date table for each ID by year (year used is Date[Year], but I get similar results from Calendar[Year] and ActiveEmployee[ID] table)

 

adj87_2-1640106792020.png

I'm unsure if this is a problem with the relationships or an issue with the measure itself

Hi, @adj87 ;

This is due to the relationship is willing to cause, could you share your model relationship, or simple file?

Best Regards,
Community Support Team_ Yalan Wu

I figured out my issue now. I was using my Calendar table instead of the created date table ID/Year reference. I just needed to add my commission/bonus totals with the correct relationship

Here is my current relationship model... I will work on getting a simplified file. Everything is either linked from ID to Active table to Pay Date to Calendar table

 

adj87_0-1640196294081.png

 

I was unsure how to handle the created table (I called 'YearDate').

 

You would use the new table in a slicer, a crossjoin, or both.

 

Nice clean data model.

lbendlin
Super User
Super User

You can (and should) do this in DAX.  Keep your reference table, and also have a calendar table in your data model.  Then you can create a measure that compares the year in the current filter context to the reference table and picks the value that is listed for that year, or for the max year that is lower than the filtered year.

Thanks for the reply. I tried to do something like this as a new Column to see if the concept was on track and I figured I would just add "Date.Add(Pay[Year],1,YEAR)" to fill in the missing years, but I can't add this to a new column and adding a new measure results in syntax errors for Earlier(Pay[Year]), Pay[Year] and [Prorated Salary]

 

I think I'm missing a step on where this could actually fill down from 2018 for example to 2021. I think this could fill in 2018 to 2019, but I don't know if it could fill the gap to 2021.

 

I added an additional measure: "prorated salary" since many of our people do recevie salary changes (or more than 1) midyear and we need to sum those up to the total they were paid for the given year.

 

Any assistance would be great!

 

Annual Salary = 
var maxyear = MAX('Calendar'[Year])
var last_payment = CALCULATE(SUM([Prorated Salary]),
                       FILTER(Pay,Pay[Year]=EARLIER(Pay[Year])-1))
return
IF(Pay[Year] < maxyear,last_payment, [Prorated Salary])

 

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.