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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
szczawek
Frequent Visitor

Max Year as single measure value to use as condition for other measures

Hello,

 

I am stuck with figuring out what MayYear measure should be set in dax so i can recive a single value.

 

When i use dax for MaxYear as:

 

MaxYear = 
var Max_ID_Date= 
CALCULATE(
    MAX(Fact[ID_Data])
    ,all(DimCalendar)
    ,Fact[Column_A]>0
)

var MaxYear=
CALCULATE(
    max(DimCalendar[Year])
    ,DimCalendar[ID_Data]=MaxIDData
    ,ALL(DimCalendar)
)
return MaxYear

 

i get the value as i want when i use this measure in Card or table.

 

However when i try to use this measure as condition i am getting Placeholder true/false error:

 

PrevYearSales=
Calculate(
    [Sales]
    ,DimCalendar[Year] = [MaxYear] -1
)

szczawek_0-1655594425430.png

 

Can anyone point out a general approach how to calcualte max Year/ID_Date to use it freely as condition in other measures?

 

Thank you in advance

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @szczawek ,

 

Try:

PrevYearSales =
CALCULATE (
    [Sales],
    FILTER ( ALLSELECTED ( DimCalendar ), DimCalendar[Year] = [MaxYear] - 1 )
)

Which table does your [Sales] formula calculate the value in? If it is a fact table, it should use fact[year]=[maxyear]-1.

 

Best Regards,

Jay

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @szczawek ,

 

Try:

PrevYearSales =
CALCULATE (
    [Sales],
    FILTER ( ALLSELECTED ( DimCalendar ), DimCalendar[Year] = [MaxYear] - 1 )
)

Which table does your [Sales] formula calculate the value in? If it is a fact table, it should use fact[year]=[maxyear]-1.

 

Best Regards,

Jay

AlB
Community Champion
Community Champion

Hi @szczawek 

Try

PrevYearSales =
VAR aux_ = [MaxYear] - 1
RETURN
    CALCULATE ( [Sales], DimCalendar[Year] = aux_ )

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.