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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Create table with MAX year week

Need help to create a table containing products with MAX (latest) year week.  Not all products have the same MAX year week.  Desired results are below,

 

Source Table:        Results Table:

Year week  Product   Year week   Product

201848       A         201848      A

201848       B         201848      B

201847       A         201847      C

201847       B

201847       C

 

I am using Power BI Desktop - need a DAX solution or M code.  Maybe an "IsMax" flag and a filter..

2 ACCEPTED SOLUTIONS

The DAX formula depends on the table structure. But assuming you have one table of data loaded in power BI  called Table then just do this

 

create a table visual on a report page

drag the Table[Product] Column to the table visual

write a measure = max(Table[Year Week])

place the measure in the table visual



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

v-lili6-msft
Community Support
Community Support

HI, @Anonymous

After my research, you could use EARLIER to calculate the max year week for each Product and then mark an "IsMax" flag for filter.

For example:

TAG = IF( CALCULATE(MAX('Table'[Year week]),FILTER('Table','Table'[Product]=EARLIER('Table'[Product] )))='Table'[Year week],"IsMax","IsNotMax")

16.JPG

Then use this column to filter data.

 

Best Regards,

Lin

 

 

 

 

Community Support Team _ Lin
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

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

HI, @Anonymous

After my research, you could use EARLIER to calculate the max year week for each Product and then mark an "IsMax" flag for filter.

For example:

TAG = IF( CALCULATE(MAX('Table'[Year week]),FILTER('Table','Table'[Product]=EARLIER('Table'[Product] )))='Table'[Year week],"IsMax","IsNotMax")

16.JPG

Then use this column to filter data.

 

Best Regards,

Lin

 

 

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

The DAX formula depends on the table structure. But assuming you have one table of data loaded in power BI  called Table then just do this

 

create a table visual on a report page

drag the Table[Product] Column to the table visual

write a measure = max(Table[Year Week])

place the measure in the table visual



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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