Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
powerbiss
Helper I
Helper I

Sum Distinct values based on string values

Hi Team,
I am trying to sum distinct values from amount_total column based on state and invoice_status columns. State should be "draft" and invoice_status should be "no"

Answer: 200000

 

Thanks for all your helpsum_values_strings.png

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

create a measure like

Sum of distinct values =
var distinctAmounts = CALCULATETABLE(VALUES('Table'[amount_total]), 
TREATAS( { ( "draft", "no") }, 'Table'[state], 'Table'[invoice_status])
)
return SUMX(distinctAmount, [amount_total])

View solution in original post

3 REPLIES 3
powerbiss
Helper I
Helper I

Hi John,

Really appreciate your help in solving my problem. What is TREATAS.

Your solution worked great.

 

Thanks again

TREATAS is a means of moving or creating filters. If you want to filter a number of columns by different values then you can create a table using {} table constructor and then use TREATAS to say this column of this table matches the first value, this column of that table matches the 2nd value etc.

Also handy if you want to move an existing filter from one table to another, e.g. TREATAS(VALUES('Table1'[id]), 'Table2'[id])

johnt75
Super User
Super User

create a measure like

Sum of distinct values =
var distinctAmounts = CALCULATETABLE(VALUES('Table'[amount_total]), 
TREATAS( { ( "draft", "no") }, 'Table'[state], 'Table'[invoice_status])
)
return SUMX(distinctAmount, [amount_total])

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.