Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
nisansala23
New Member

Get the highest value from selected date range

Hi,

I'm trying to get the highest value from a date range. below I have mentioned my dax code. it only returns the value related to slicer end date, not the highest value of the date range. Can anyone help me to figureout the issue

 

HIGHEST_ASPI_VAL =
var _year = SELECTEDVALUE('DATE'[YEAR])
var _yearstart = DATE(_year, 1, 1)
var _endDate = SELECTEDVALUE('DATE'[Date])
var ASPI_VAL = CALCULATE(MAX(BI_SECTOR_HISTORIES[SECTORIAL_INDEX]),
    FILTER(BI_SECTOR_HISTORIES,BI_SECTOR_HISTORIES[SECTOR_DATE] >= _yearstart
        && BI_SECTOR_HISTORIES[SECTOR_DATE] <= _endDate))
var Result =
IF(
    NOT( ISBLANK(
        SUM(BI_SECTOR_HISTORIES[SECTORIAL_INDEX]))),
        ASPI_VAL, BLANK())
        return
        Result
2 REPLIES 2
BrianConnelly
Resolver III
Resolver III

If you are trying to get the highest value within a selected date range, try using the Allselected...

var ASPI_VAL = CALCULATE(MAX(BI_SECTOR_HISTORIES[SECTORIAL_INDEX]),
  ALLSELECTED(BI_SECTOR_HISTORIES[SECTOR_DATE]))
      
tamerj1
Super User
Super User

Hi @nisansala23 
Please try

HIGHEST_ASPI_VAL =
MAXX (
    DATESYTD ( 'Date'[Date] ),
    CALCULATE ( MAX ( BI_SECTOR_HISTORIES[SECTORIAL_INDEX] ) )
)

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.