cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
almafater2
Helper I
Helper I

MIn and Max dates in selection

Hi, community,

 

I am trying to calculate the difference between the biggest and lowest values in this table in the selected range of dates. 

almafater2_0-1625044305833.png

 

In this case the the desired result would be a dax measure that would calculate:

VerteX on lowest date in selection (31320000)  - VerteX on the biggest date on selection (27380000) = 3940000. 

 

How do I identify the min and max dates in the selection? 

 

The formula for VNT VertėX =

CALCULATE(

SUMX('VNT Vertės', 'VNT Vertės'[InvestmentUnitValueEntEY.Unit_Value] * [VNT Skaičius]),
FILTER(ALL(Dates[Date]), Dates[Date] <= MAX(Dates[Date])))
 
Ataching link with PBI file example:
 
1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @almafater2 ,

 

You can use the following measure:

 

Measure = FIRSTNONBLANKVALUE(Dates[EndOfMonth],[VNT VertėX])-LASTNONBLANKVALUE(Dates[EndOfMonth],[VNT VertėX])

 

Capture51.PNG

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

2 REPLIES 2
v-deddai1-msft
Community Support
Community Support

Hi @almafater2 ,

 

You can use the following measure:

 

Measure = FIRSTNONBLANKVALUE(Dates[EndOfMonth],[VNT VertėX])-LASTNONBLANKVALUE(Dates[EndOfMonth],[VNT VertėX])

 

Capture51.PNG

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

amitchandak
Super User IV
Super User IV

@almafater2 , try a measure like

 

measure =
var _max = MAXX(allselected('Dates'), 'Dates'[Date])
var _min = MAXX(allselected('Dates'), 'Dates'[Date])
return
CALCULATE(
SUMX('VNT Vertės', 'VNT Vertės'[InvestmentUnitValueEntEY.Unit_Value] * [VNT Skaičius]),
FILTER((Dates[Date]), Dates[Date] = _max)) - CALCULATE(
SUMX('VNT Vertės', 'VNT Vertės'[InvestmentUnitValueEntEY.Unit_Value] * [VNT Skaičius]),
FILTER((Dates[Date]), Dates[Date] = _min))



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Kudoed Authors