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.
i am trying to calculate total sales by max date and product. So when the date filter changes the value should shift to the new max date this needs to be done in a measure but when i currently use the following i get the correct number but whne put in a tbale with the products its the grand total of sales duplicated for each product
CALCULATE(SUM('table1'[value]),ALLEXCEPT('table1','table1'[product]),FILTER( ALL('table1'), 'table1'[Date] = Max('table1'[Date])))
Solved! Go to Solution.
Hi @Anonymous
Create measure
Measure =
VAR maxdate =
CALCULATE (
MAX ( 'Table'[date] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[product] = MAX ( 'Table'[product] ) )
)
RETURN
CALCULATE (
SUM ( 'Table'[sales] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[product] = MAX ( 'Table'[product] )
&& 'Table'[date] = maxdate
)
)
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
Create measure
Measure =
VAR maxdate =
CALCULATE (
MAX ( 'Table'[date] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[product] = MAX ( 'Table'[product] ) )
)
RETURN
CALCULATE (
SUM ( 'Table'[sales] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[product] = MAX ( 'Table'[product] )
&& 'Table'[date] = maxdate
)
)
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , Try like
sumx(values(Table[product]),lastnonblankvalue(Table[sales date],sum(Table[sales])))
@Anonymous
Please share the sample data.
I think if you use date filter, you don't need to calculate the maxdate. The value will change by changing the date filter.
CALCULATE(SUM('table1'[value]),ALLEXCEPT('table1','table1'[product]))
Proud to be a Super User!
@ryan_mayu thank you but i need to as i only want the sum of the latest date i dont want the sum up to latest date
@Anonymous
I am still not very clear about your scenario.
Show the latest date value by selection.
Measure =
VAR maxdate=max('Table'[date])
return CALCULATE(sum('Table'[value]),'Table'[date]=maxdate)
Always show the latest date's value
Measure =
VAR maxdate=CALCULATE(max('Table'[date]),all('Table'))
return CALCULATE(sum('Table'[value]),'Table'[date]=maxdate)
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
95 | |
80 | |
68 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |