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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
chulpanvl
Helper I
Helper I

Return blank in dax measure if data is missing

Hello!

 

I have IndicatorsData table with historical data of actual coefficients across different indicator names.

 

I want to create a table visual, which will return the average actual coefficient for each indicator name, but for the last selected year only. So, if there is a multiple selection in a year slicer, the table should display the average coefficient only for the maximum of selected years. I created a measure 

last_selected_year = MAXX(ALLSELECTED('indicatorsData'[year]),'indicatorsData'[year]).

 

However, there are missing data. And of there is no data for last_selected_year for a particular indicator, I want the table visual to display nothing.

 

I created a measure for calculating the avg coefficient. But in case of missing data it returns last non blank value, while I want it to return blank or at least 0.

 

actual_coeff_last_year = CALCULATE(AVERAGE(indicatorsData[actual_coeff]), FILTER(indicatorsData, indicatorsData[year] = [last_selected_year]))

 

Pbix file to play with.

 

 

 

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

Is this what you are looking for?
Screen Capture #312.png

View solution in original post

3 REPLIES 3
Ahmedx
Super User
Super User

read a book "Power BI DAX Simplified"  :- Chapter 7: Caution When Using Variables in DAX and Power BI

Ahmedx
Super User
Super User

Is this what you are looking for?
Screen Capture #312.png

yes, exactly! omg thanks!

could you pls explain why if I create a measure "last_selected_year" outside the "actual_coeff_last_year", the latter behaves differently than if we would create a varibale "last_selected_year" inside the "actual_coeff_last_year"? So counterintuitive...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors