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

Getting values only for the latest product

Hi Power BI Community,

I wanted to get the values/sales of only for the latest product that lunched.

DateProductSales
12/03/202212.03.202201242
18/07/202218.07.202202310
25/08/202225.08.202203156
25/08/202225.08.202204559
10.10.202210.10.2022067-


This is a dummy table and values, but my original dataset has the same formate with product names. As you can see on Date basis new products are lunching. 

Sometimes on same date, new product lunches and I only want to consider the latest one. Like 25.08.2022031 and 25.08.2022045 are lunched on same date, I just want the sales of 045 = 59 sales. And later on in future new product came (10.10.2022067), the selected values should be fetched for that new product.

Thank you

4 REPLIES 4
Greg_Deckler
Super User
Super User

@Anonymous Try this:

Measure =
  VAR __LastDate = MAX('Table'[Date])
  VAR __Table = FILTER('Table',[Date] = __LastDate)
  VAR __LastProduct = MAXX(__Table,[Product])
RETURN
  SUMX(FILTER(__Table, [Product] = __LastProduct),[Sales])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler ,

This is not working.

This DAX query only getting the sales value of first date only(12.03.2022012). Not the latest date.

I want to get the value of 25.08.2022045. The current latest one


@Anonymous See attached PBIX file below signature. The slightly modified measure below works for me and gets the last date value. Not, the modifications were due to the "-" and thus the assumption that the sales are text.

Measure = 
  VAR __LastDate = MAXX(FILTER('Table',[Sales] <> "-"),[Date])
  VAR __Table = FILTER('Table', [Date] = __LastDate)
  VAR __LastProduct = MAXX(__Table,[Product])
RETURN
  MAXX(FILTER(__Table, [Product] = __LastProduct),[Sales])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler ,

I also tried it in my dataset, but still giving me the total values rather than latest product value

dawoodrana99_0-1663802834630.png

In here you can see that product is changing from Yellow to Blue one
what I need is that when for example blue one lunched, DAX query should start summing pageviews only for blue one and if new product lunches after that it should only sum pageviews for that one
Also, I wanted to consider the pages/products that lunches for the year i.e., 2022 and so on. (But i think this is not necessary)

Thank you

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.

Top Solution Authors