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
LeaRupnik
Helper III
Helper III

valu of Max date

Hello

 

i have a DAX formula like this

Kolicina max Dat =
CALCULATE (
SUM ( List1[dejstkg] ),
FILTER ( ALL ( List1), List1[Datum] = MAX (List1[Datum] )),
VALUES(List1[Naziv enote])
)
but I would like to have chosen max date (datum) in this sample is 14.03.2021.
sample: 

 

example

https://drive.google.com/file/d/1QWQSrfPIeHr1W6NiYuVgkvIpMrNRE8As/view?usp=sharing

 

 

thx

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @LeaRupnik 

Please try to replace the measure with the below.

If you change your DATUM column to date-only-type, it will be easier to write the measure.

 

Kolicina max Dat V2 =
VAR maxdate =
DATE ( YEAR ( CALCULATE ( MAX ( List1[datum_posnetka] ), ALL ( List1 ) ) ), MONTH ( CALCULATE ( MAX ( List1[datum_posnetka] ), ALL ( List1 ) ) ), DAY ( CALCULATE ( MAX ( List1[datum_posnetka] ), ALL ( List1 ) ) ) )
VAR currentnazivenote =
MAX ( List1[Naziv enote] )
RETURN
CALCULATE (
SUM ( List1[dejstkg] ),
FILTER (
ALL ( List1 ),
DATE ( YEAR ( List1[Datum] ), MONTH ( List1[Datum] ), DAY ( List1[Datum] ) ) = maxdate
&& List1[Naziv enote] = currentnazivenote
)
)

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


amitchandak
Super User
Super User

@LeaRupnik , Try like

 

Kolicina max Dat =
var _max = maxx(allselected(List1),List1[Datum])
return
CALCULATE (
SUM ( List1[dejstkg] ),
FILTER ( ALL ( List1), List1[Datum] = _max),
VALUES(List1[Naziv enote])
)

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