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
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])

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])

Anonymous
Not applicable

You are Super!!!

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.