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
CloudMonkey
Post Prodigy
Post Prodigy

DAX variable to find earliest date on a graph's x axis

Hello,

 

I have tried the below code to find the earliest date on a graph's x axis...

 

VAR
    MinimumAxisWeek = min(ALLSELECTED('Calendar - Days'[Calendar Date (week bins)]))

 

.... but I am getting the error below:

 

"The MIN function only accepts a column reference as an argument."

 

Please could someone point me in the right direction?

 

Thanks,

 

CM

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Hi @CloudMonkey ,

 

The ALLSELECTED function gets the context that represents all rows and columns in the query, while keeping explicit filters and contexts other than row and column filters. You can also simply understand that the return value is a table.

Try to modify the formula like this:

 MinimumAxisWeek = CALCULATE(MIN('table'[date]),ALLSELECTED('table'[date]))

 

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

amitchandak
Super User
Super User

@CloudMonkey 


measure =
VAR
MinimumAxisWeek = minX(ALLSELECTED('Calendar - Days'),'Calendar - Days'[Calendar Date (week bins)])
return
MinimumAxisWeek

danno
Resolver V
Resolver V

hi, 

the error message is correct, sometimes you need to combine these simple dax functions to get what you want.  

 

Use Min function to refer the date table, or column that you are using in your measure.   But then use the CALCULATE function to change the filter context of your measure so that it takes into account the selected values, perhaps something like: 

CALCULATE(MIN(Date[Date]), ALLSELECTED (Date[Date]))

(I haven't tested it out, but give it a go)

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.