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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
_fmigg
Regular Visitor

Create a Calculated Column (or one-column table) as VAR using criteria.

Hi, 

 

I'm trying to create a measure that indicates with a 1 or 0 based on the following data: 

 

Year	Month
2019	Jan
2019	Feb
2019	Mar
2019	Apr
2019	May
2019	Jun
2019	Jul
2019	Aug
2019	Sep
2019	Oct
2019	Nov
2019	Dec
2020	Jan
2020	Feb
2020	Mar

If the Month exists in the MAX Year, I will return a 1, otherwise 0. 

 

So the measure should work like this if is added to a visual table: 

Year	Month	isMonthInMaxYear
2019	Jan	1
2019	Feb	1
2019	Mar	1
2019	Apr	0
2019	May	0
2019	Jun	0
2019	Jul	0
2019	Aug	0
2019	Sep	0
2019	Oct	0
2019	Nov	0
2019	Dec	0
2020	Jan	1
2020	Feb	1
2020	Mar	1

I can't solve it statically because at the future there will be more records on the table and the 1's will be changing over time. 
I can't create more tables at the data model (nor calculated tables or Power Query tables).


What I'm trying to do is to have a table a one-column table as VAR on the measure, but I'm kind of stuck because VALUES function doesn't accept criteria, SUMMARIZECOLUMNS asks for an index column in which criteria can't be applied and CALCULATE TABLE will return the table with Year and Month columns. 


I'd like to have a table with the months of the highest year in a VAR, so the table would look like this. 

Month
Jan
Feb
Mar

 

And then use it on a condition using the IN function, but I'm stuck on the previous step.

 

Is it possible to do that? Is this approach correct? 

 

Thanks

1 REPLY 1
v-lili6-msft
Community Support
Community Support

hi, @_fmigg 

You could try this formula logic to create a measure:

Measure = var _maxyear=CALCULATE(MAX('Table'[Year]),ALLSELECTED('Table'))
var _table=CALCULATETABLE(VALUES('Table'[Month]),FILTER(ALLSELECTED('Table'),'Table'[Year]=_maxyear)) return
IF(SELECTEDVALUE('Table'[Month]) IN _table,1,0)

of course, you could use ALL instead of ALLSELECTED in the formula

1.JPG

and here is my sample pbix, please try it.

 

Best Regards,

Lin

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

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.

Top Solution Authors