Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowData Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more
There is a very simple task, but I can't figure out how to do it.
I need to calculate how many colors of the product were sold on the last day of sale for each product.
table 1
table 2
my measure
lastColorSaleCount =
var maxdate = max(sales[date])
var filtertable =
ADDCOLUMNS(
sales,
"maxdatefilter",
CALCULATE(MAX(sales[color_id]), FILTER(sales, sales[date] = maxdate)))
return
COUNTX(filtertable,[maxdatefilter])
But I need to get
Please, I would be glad to help you in any way
Solved! Go to Solution.
Hello,
i just changed Max(color_id) to Distinct(Color_id)
and then the measure:
hello, this is very lengthy but might help:
(i used calculated column)
Hi, thanks for the help, but it only works on numeric fields. i made a simplified model, mine is much more complicated and my mistake is that i made it very simple. please help me again
Hello,
i just changed Max(color_id) to Distinct(Color_id)
and then the measure:
hello, are you trying to get which products and how many were sold on the latest date on your table? also could you explain how did you come up with the screenshot (the supposedly result) so we can help you out more?
made it with hands.
I'm looking for what colors were sold on the last dates
product 1 = color 2
product 2 = color 3
product 3 = color 2
total
color 2 - 2
color 3 - 1
Try
Sales on last day =
SUMX (
'Product',
VAR LastSaleDate =
CALCULATE ( MAX ( 'Sales'[Sale date] ) )
RETURN
CALCULATE ( COUNTROWS ( 'Sales' ), 'Sales'[Sale date] = LastSaleDate )
)
I'm sorry, I see a different result
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 23 | |
| 21 | |
| 20 | |
| 19 | |
| 13 |
| User | Count |
|---|---|
| 58 | |
| 52 | |
| 37 | |
| 31 | |
| 27 |