Forum Discussion
Help in implementing a logic in DAX
Hi Guys,
Please find the sample dataset in the screenshot attached above. I have three tables in my dataset.
The logic to be implemented is,
I want to categorize the users who got error on their first migration date as YES, and who didn't get any error on their first migration date as NO.
The result for the sample data would be 2 yes (user 1 and user 2) and 1 no(user 3).
Need some help in implementing the same in DAX.
Thanks in advance
AishwariyaV , if you need new column in Table1. You need following columns
new column Table 2
C1 = minx(filter(Table1, Table[User] = table2[User] ), table1[first Migration Date])
new column Table 2
C2 = countx(filter(Table3, Table3[Date] = table2[C1] && Table3[Status] = "Failed"), table3[Error Message])
New column in Table 1
c3 =
var _1 = countx(filter(Table2, Table[User] = table2[User] && not(isblank([C2])) ), table2[c2])
return
if(not(isblank(_1)), "Yes", "No")- Anonymous4 years ago
You can just create the following measure. Here is the relationship, you may check the pbix for detail.
Measure = IF(CALCULATE(MAX('Table (3)'[Error message]),FILTER('Table (3)',[Date]=MAX('Table'[First migration date])))="Error","Yes","No")Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
2 Replies
- amitchandak
Super User
AishwariyaV , if you need new column in Table1. You need following columns
new column Table 2
C1 = minx(filter(Table1, Table[User] = table2[User] ), table1[first Migration Date])
new column Table 2
C2 = countx(filter(Table3, Table3[Date] = table2[C1] && Table3[Status] = "Failed"), table3[Error Message])
New column in Table 1
c3 =
var _1 = countx(filter(Table2, Table[User] = table2[User] && not(isblank([C2])) ), table2[c2])
return
if(not(isblank(_1)), "Yes", "No") - AnonymousNot applicable
You can just create the following measure. Here is the relationship, you may check the pbix for detail.
Measure = IF(CALCULATE(MAX('Table (3)'[Error message]),FILTER('Table (3)',[Date]=MAX('Table'[First migration date])))="Error","Yes","No")Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.