Forum Discussion
DAX - measure filtered by another measure with SUMMARECOLUMNS - equivalent of T-SQL GROUP, HAVING,..
- 1 year ago
Thanks for your idea; I believe I got this; only thing, you did not include the Job in your formula; in my actual project, I have duplicate of employee names and jobs; so it is essential I use DISTINCTCOUNT function for any type of count.
Active Multi Job1_Measure = VAR x_CT = SUMMARIZECOLUMNS( EmployeeTable[EmployeeId], TREATAS({"Y"},EmployeeTable[IsActiveEmployee]), "DistinctCountOfJobs_Measure",DISTINCTCOUNT(EmployeeTable[Job]) ) RETURN COUNTROWS( FILTER( x_CT, [DistinctCountOfJobs_Measure] > 1 ) )Can you validate the above code, whether it is fool-proof ? I tried this new measure in the Power BI file, it is good. Your idea to use SUMMARIZECOLUMNS proved very useful; I used the syntax from here.
Thanks lbendlin
Does this also work when the IsActiveEmployee value changes across Jobs ? Say, I have James and Jack below, I want Jack to be included, but not James, even though both have multiple jobs; Jack has had two jobs while being active, while James has had only one job while being active.
Now, I need the answer to change to 4. Is your DAX code a fool-proof solution to such changes ?
(I know, I did not post this scenario earlier, because I wanted the question to be as simple as possible, to start with.)
Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.
- snph17771 year ago
Helper V
See the Power BI file and Excel file; everything stated there.
- lbendlin1 year ago
Super User
yes, same formula still works.
- snph17771 year ago
Helper V
I have another scenario, where there are duplicate entires. I need to have DISTINCTCOUNT.
(EmployeeId and EmployeeName are tied to each other though; an EmployeeId always refers to one EmployeeName only)
See the Power BI and Excel here.
I think I am good; but just in case, if you anything to comment, please let me know.
It was really great to learn a very common applucation of SUMMARIZECOLUMNS.
- snph17771 year ago
Helper V
Thanks for your idea; I believe I got this; only thing, you did not include the Job in your formula; in my actual project, I have duplicate of employee names and jobs; so it is essential I use DISTINCTCOUNT function for any type of count.
Active Multi Job1_Measure = VAR x_CT = SUMMARIZECOLUMNS( EmployeeTable[EmployeeId], TREATAS({"Y"},EmployeeTable[IsActiveEmployee]), "DistinctCountOfJobs_Measure",DISTINCTCOUNT(EmployeeTable[Job]) ) RETURN COUNTROWS( FILTER( x_CT, [DistinctCountOfJobs_Measure] > 1 ) )Can you validate the above code, whether it is fool-proof ? I tried this new measure in the Power BI file, it is good. Your idea to use SUMMARIZECOLUMNS proved very useful; I used the syntax from here.