Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello,
I am attempting to create a measure that will return the distinct count of a specific type of customer (New Tank Distributor) that is set up in any given year. After attempting simple measure and calculated table approaches, I believe the only solution that will work for my situation is a virtual table(s) that is then aggregated down to the single scalar value: the sum or count of New Tank Distrubtors over any filtered period of time.
Here are the two variable virtual tables I've create which get me very close. Only thing I am missing is how to produce a single value for New Tank Distributor instead of a row that contain's its label & count. Any advice how to rework the second VAR to produce a scalar value instead of table?
Note: I label each "distributor type" in the first virtual table because once I figure out how to create this measure, I will reproduce it for the other distrubutor types as well.
New Tank Distributor =
Solved! Go to Solution.
well, you can t use summarizecolumns in measure
try using addccolumns ( summarize ( .. ) instead .
and for the return, just return aggregation without the { } .
the { } were only needed for the query not to be used in the measure.
hope this makes sense.
to return a scalar value from the second table , assuming that this returns only one row :
VAR _aggtable =
selectcolumns(,
FILTER(
GROUPBY(
_summarytable,
[Distributor Type],
"Number Of Customers", COUNTX( CURRENTGROUP(),1)
),
[Distributor Type]="New Tank Distributor"
),
[Number Of Customers]
)
if it returns multiple rows, then you need to either filter to one row, or to use one of the iterators base on your business logic :
sumx , maxx, minx, . ..
let me know if thelps.
Thanks for the response!
Your solution does help to return a single row and column, which is the closest I've come so far. However it does not appear it is a pure scalar value because I cannot throw it in a card to display the single value on my dashboard.
Is it possible to run one of the aggregator functions over to entire result of the second virtual table?
Thank you,
Matt
you can use maxx or minx if you are sure that you have 1 value . or you have multiple values all the same. @mmahoney045
It appears to be only a single value, judging from the output. How would the MAXX wrap arround the groupby statment? I tried, but my attempt failed.
[Number Of Customers]
"1182"
VAR _aggtable =
maxx(,
FILTER(
GROUPBY(
_summarytable,
[Distributor Type],
"Number Of Customers", COUNTX( CURRENTGROUP(),1)
),
[Distributor Type]="New Tank Distributor"
),
[Number Of Customers]
)
should be something like this.
Ah, sorry. the error states: The 3 argument to the MAXX function contains a flag that is not supported.
Its bizarre that converting a table value to scalar is this difficult.
Here is the code:
I tried that and unfortunately the error changes to "The expression specified in the query is not a valid table expression".
because it is returning a scalar value, you cant use it like this when authoring a dax query
to be able to see it in the query editor,, write the evaluate like this :
evaluate { _aggtable }
It worked in DAX editor , but not when I went to set up the measure in the visualization page. Any other changes necessary to make this scalar work in a measure?
DAX editor result:
Measure Code:
well, you can t use summarizecolumns in measure
try using addccolumns ( summarize ( .. ) instead .
and for the return, just return aggregation without the { } .
the { } were only needed for the query not to be used in the measure.
hope this makes sense.
This worked Daniel. Thank you!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |