Showing results for 
Search instead for 
Did you mean: 
Frequent 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');

Frequent Visitor

SUMX (VALUES('Table'[Amount] ), CALCULATE(DISTINCT('Table'[Scrid] ), 'Table'[datanameshort]="name'"&& 'Table'[status] = "status"))
Solution Sage
Solution Sage

Hi @MDR ,
Try this.
SUM( 'Table'[Amount] ),
CALCULATE ( DISTINCT ( 'Table'[Scrid] ) , 'Table'[datanameshort]='name' and 'Table'[status] = 'status)
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

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.

Helpful resources

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors