Forum Discussion
Unexpected return from TREATAS function
Hi gvg
There are two records on 2018/1/1 with the same product id. The amount in the highlighted row is from John's amount rather than Peter's amount. In this measure, TREATAS returns all the values exist in both Managers table's Mgr column and Sales table's Manager column, so the result is John and Sam. It calculates the total amount of John and Sam's sales.
In image below, I use CONCATENATEX to combine the results returned by TREATAS(VALUES(Managers[Mgr]),Sales[Manager]) part. You will find Peter is excluded as expected.
TestTreatas5 = CONCATENATEX(TREATAS(VALUES(Managers[Mgr]),Sales[Manager]),[Manager],", ")
In your second measure
TestTreatas5 =
CALCULATE(SUM(Sales[Amount]),VALUES(Sales[Manager]),TREATAS(VALUES(ManagerTable[Manager]),Sales[Manager]))
VALUES(Sales[Manager]) part works as an additional filter in CALCULATE expression. On rows having "Peter", VALUES(Sales[Manager]) returns "Peter" while "Peter" doesn't exist in the result of TREATAS part, so the filtered result is blank.
Reference:
A Deep Dive Into The TREATAS DAX Function In Power BI | Enterprise DNA
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Hi v-jingzhang ,
Thank you for your explanation. Could you please elaborate on this part "On rows having "Peter", VALUES(Sales[Manager]) returns "Peter" while "Peter" doesn't exist in the result of TREATAS part.". If VALUES part is omitted, don't "Peter" row in the visual filter Sales leaving only the single row "1/1/2018 Peter" visible for CALCULATE?