Forum Discussion
Trying to get Max value using a column parameter
hello aliahad
as far as my knowledge, MAX() only accept column that has been defined.
DAX doesnt accept force command as my example above.
instead, you can do as below.
Hope this will help.
Thank you.
- aliahad1 year agoFrequent Visitor
Hi Irwan
The DAX expression you provided is giving me max value for all the rows.
Column = CALCULATE( MAX('Head Count'[MONTH]), FILTER('Head Count', 'Head Count'[RowNumberYear] = 1) )So in my dataset I have YEAR and MONTH, and I trying to get 1 or 0 in the calculated column for max year and month, so the current max month I got in the dataset is 5 and current max year is 2025, but when I new data for June I want current max month = 6 and current max year = 2025 and next month the max month will be July. So I am trying to create a flag using the calculated column.
Thanks,
Ali.
- aliahad1 year agoFrequent Visitor
Hi Irwan ,
I tried the expression you provided, it gives me the 'MAX' for all the rows in the dataset.
So in my dataset I have a column 'MONTH' and 'YEAR' and I need to get a calculated column that gives me 1 for 'MAX' month and 'MAX' year, and 0 for all the remainder rows. The current dataset got max year as 2025 and max month as 5, and in my column I need 1 for MAX year 2025 and MAX month 5 and 0 for remainder of the rows. This should switch when the June data is added to the dataset.
I hope I have clarify the ask.
Thanks,
Ali.
- Irwan1 year ago
Super User
hello aliahad
i assumed you want to get MAX value of your date (max month AND max year).
Here is a simple example.
Check =
var _Max = MAX('Table'[Date])
Return
IF(
'Table'[Date]=_Max,
1,
0
)but if you need separate column between month and year, then please try this.
Check Month =
var _Max = MAX('Table'[Month])
Return
IF(
MONTH('Table'[Date])=_Max,
1,
0
)Check Year =
var _Max = MAX('Table'[Year])
Return
IF(
YEAR('Table'[Date])=_Max,
1,
0
)Hope this will help.
Thank you.