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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
iabelze
New Member

DAX populate values from different table for latest date

Hi there, 

 

I'm completely new to Power BI and DAX, and have run into an issue that I do not know how to solve. I have 3 tables and need to create a matrix, that would populate values from each table. 

 

Table 1:

datecategory subcategorystatus
1/1/2023A1new
1/1/2023A2ongoing
1/1/2023A3new
1/1/2023B1ongoing
1/1/2023B2ongoing
1/1/2023B3ongoing
3/5/2023A1ongoing
3/5/2023A2ongoing
3/5/2023A3ongoing
3/5/2023B1done
3/5/2023B2done
3/5/2023B3done
5/7/2023A2done
5/7/2023B3done

 

Needed Matrix for the latest date (5/7/2023):

 123
Aongoingdoneongoing
Bdonedonedone

 

I have also created two additional connected helper tables, one listing all 'categories', and another listing all 'subcategories'. That way when I build the matrix, I can add helper table values in rows and columns to avoid the matrix excluding values if there was no value reported for the most recent date. 

 

Currently, I am only able to get a matrix that uses ONLY values for the latest date and omits the rest:

 123
A done 
B  done

 

To populate the matrix values, I am using a formula:

most recent status =
var thisdate = CALCULATE(MAX(table[date]))
var previousdate = CALCULATE(MAX(table[date]), table[date] < thisdate)RETURN IF(
thisdate <> BLANK(),
SELECTEDVALUE(table[status]),
(CALCULATE(MAX(table[status]), table[date] = previousdate)))

 

 

 

However, it will not add a 'status' that was reported previously but not for the most recent date. Instead, that cell will be left blank. 

How do I adjust the measure to report previous values if they have not been reported for the most recent time period? 

 

Thank you! 

2 REPLIES 2
tamerj1
Super User
Super User

Hi @iabelze 

It is allways good to have a Date table. However, based on your current conditions please try

most recent status =
MAXX (
TOPN (
1,
CALCULATETABLE ( 'Table', 'Table'[Date] <= MAX ( 'Table'[Date] ) ),
'Table'[Date]
),
'Table'[Status]
)

iabelze
New Member

note to add: this matrix will be used with a "date" filter

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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