Forum Discussion
SilvioLunaPBI
5 years agoFrequent Visitor
Calculate count into calculaltetable
I have this code in dax, I need to be able to execute the code that is marked as "<-- ERROR", using the table variable.
var tb = CALCULATETABLE(
SELECTCOLUMNS(RawData
,"service",RawData[Service]
,"period",RawData[StartOfPeriod_]
,"volume",RawData[Contact Volume]
,"position",RawData[Position]
))
var tb2 = CALCULATETABLE(
SELECTCOLUMNS(tb
,"service",[service]
,"period",[period]
,"volume",[volume]
,"position",RANKX(FILTER(
tb,
[service] = EARLIER([service]) &&
[period] = EARLIER([period])),[position],,ASC,Dense)
,"vendors",CALCULATE(COUNT([service]),ALLEXCEPT(tb,tb[StartOfPeriod_],tb[Service])) <-- ERROR
))
3 Replies
- amitchandak
Super User
SilvioLunaPBI , Try like
addcolumns(summarize(tb
,"service",[service]
,"period",[period]
,"volume",[volume])
,"position",RANKX(FILTER(
tb,
[service] = EARLIER([service]) &&
[period] = EARLIER([period])),[position],,ASC,Dense)
,"vendors",CALCULATE(COUNT(tb[service]),ALLEXCEPT(tb,tb[StartOfPeriod_],tb[Service]))
)Can you share a sample pbix after removing sensitive data.
- SilvioLunaPBIFrequent Visitor
I need to do it all in the measure not in calculated columns, I need to use dynamic filter all in measure
this is an example of file: https://drive.google.com/file/d/1e-PTQHjC-fFvhGMQiYNpNFW_67gBBZe8/view?usp=sharingTks
- SilvioLunaPBIFrequent Visitor
Any help?