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

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

Reply
Anonymous
Not applicable

Create new table from other table and keep rows with most recent dates filtered by unique values

Hey everyone,

 

I just figured out that I need to reduce my main table to a smaller, new table with just the most recent rows. 

These rows should contain only the most recent rows depending on the unique values on the column "CAD-NR.".

 

As an example, please have a look on this picture:

 

Ex.JPG

 

I tried with summarize and groupby, but I didn't succeed:

 

GoupBy Test =
GROUPBY(Messdaten_Entpivotiert;Messdaten_Entpivotiert[CAD-NR.];Messdaten_Entpivotiert[Attribut];"Attribut";maxx(CURRENTGROUP();Messdaten_Entpivotiert[Datum].[Date])
)
 
---> I get just some columns, I would need all columns from the main table
 
GroupEnCADNR = SUMMARIZE(Messdaten_Entpivotiert;Messdaten_Entpivotiert[CAD-NR.];"Datum";MAX(Messdaten_Entpivotiert[Datum]);"Typ";MIN(Messdaten_Entpivotiert[Typ]))

 

--> Since I always have to choose a min or max, also for text values, I get wrong values

 

Thnak you for your help I am stuck 

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @Anonymous 

NewTable =
FILTER (
    Table1,
    Table1[Date] = CALCULATE ( MAX ( Table1[Date] ), ALLEXCEPT ( Table1, Table1[CAD-NR] ) )
)

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

6 REPLIES 6
mahoneypat
Microsoft Employee
Microsoft Employee

Two things to consider.  If you will never need these older rows, this should be done in the query editor on your main table, so you are not storing some of your data twice.  Or, you can likely do the needed calculations with a measure and also not create another table with your model.  Would either approach be acceptable?

 

If you still need a DAX table created, it can likely be done with an expression that creates a virtual table of your CAD-NR values and the max date for each, and then doing a join of that table with your original table to get your desired result.

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hey @mahoneypat ,

 

thanks for your advices that conscern the whole process.

 

I would prefer to solve this challenge with a virtual table and only measures, but I don't know how.

 

Could you give me some information about how I could implement that?

Greetings from Austria 🙂

AlB
Community Champion
Community Champion

@Anonymous 

You can use the same code I shared earlier to create the virtual table as a VAR within in a measure. Do note the code might need some tweaking to account for filter context, which was not present when we created the calculated table:

 

Measure =
VAR fTable_ = //This is the virtual table, with same code as earlier
FILTER (
    Table1,
    Table1[Date] = CALCULATE ( MAX ( Table1[Date] ), ALLEXCEPT ( Table1, Table1[CAD-NR] ) )
)
RETURN
//and then use the virtual table here as needed

 

 Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

Hi,

 

@mahoneypat thx!

 

I get an error if I just want to return this table or the sum of a column of this table.

 

How should I work with such a virtual table?

BR

 

 

AlB
Community Champion
Community Champion

@Anonymous 

I assume you are addressing me and not @mahoneypat 

I would need more details on what you are trying to do exactly how you are using the measure. Try this measure in a card visual to sum the contents of one of the  (numerical) table columns: 

 

Measure =
VAR fTable_ = //This is the virtual table, with same code as earlier
FILTER (
    Table1,
    Table1[Date] = CALCULATE ( MAX ( Table1[Date] ), ALLEXCEPT ( Table1, Table1[CAD-NR] ) )
)
RETURN
SUMX(fTable_, [NameOfColumnToSum]) //Use the name of your column here, instead of "NameOfColumnToSum" 

 

Bear in mind that a measure cannot return a table, only scalars.

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

 

AlB
Community Champion
Community Champion

Hi @Anonymous 

NewTable =
FILTER (
    Table1,
    Table1[Date] = CALCULATE ( MAX ( Table1[Date] ), ALLEXCEPT ( Table1, Table1[CAD-NR] ) )
)

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors