Forum Discussion
Create Measure From Virtual Table
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 =
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.
14 Replies
- Daniel29195Community Champion
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.
- mmahoney045Regular Visitor
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
- Daniel29195Community Champion
you can use maxx or minx if you are sure that you have 1 value . or you have multiple values all the same. mmahoney045