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
Anonymous
Not applicable

Easy correction in DAX, replacing hardcoded vale in measure

I am trying to get all ids list from my table which has all the versions and so my below code works perfectly fine if my Id expects 2 versions, here I have hardcoded max  = 2 but instead of 2 if I write DistinctCount(Table1[version]) it doesnot seems to be binding.

though I can see DistinctCount(table1[version]) returns the same value.

What wrong am I doing here?? I am trying to use it in matrix visual with Ids in row and version 1 and version 2 as columns

 

Measure which works fine:

Measure=

var _max= 2
return
countx(filter(summarize(Table, Table[Id], "_1",distinctcount(table[Version])),[_1] ?_max),[Id])

 

Table is something like this:

IDVersion
11
12
21
31
32

 

Measure which does not work fine:

 

Measure=

var _max= DistinctCount(Table1[version])
return
countx(filter(summarize(Table, Table[Id], "_1",distinctcount(table[Version])),[_1] ?_max),[Id])

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try like

Measure=

var _max= calculate(DistinctCount(table1[version]), allselected(table1))
return
countx(filter(summarize(Table, Table[Id], "_1",distinctcount(table[Version])),[_1] = _max),[Id])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Try like

Measure=

var _max= calculate(DistinctCount(table1[version]), allselected(table1))
return
countx(filter(summarize(Table, Table[Id], "_1",distinctcount(table[Version])),[_1] = _max),[Id])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

You are Super!!!

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
Top Kudoed Authors