Forum Discussion
MDR
3 years agoFrequent Visitor
Convert SQL query to a DAX measure, calculate sum for distinct values in another column
What is an equivalent DAX measure for the following SQL query: select sum(amount) from (select distinct srcid, amount from mytable where datanameshort='name' and status = 'status');
pratyashasamal
Memorable Member
3 years agoHi MDR ,
Try this.
SUMX (
SUM( 'Table'[Amount] ),
CALCULATE ( DISTINCT ( 'Table'[Scrid] ) , 'Table'[datanameshort]='name' and 'Table'[status] = 'status)
)
Thanks,
Pratyasha Samal
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
MDR
3 years agoFrequent Visitor
Thanks pratyashasamal this returns the following error:
The SUMX function expects a table expression for argument '1', but a string or numeric expression was used.