Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
In the healthcare field, it is often desireable to identify a cohort of patients with similar, multiple diagnoses. This quick measure returns a comma-delimited list of patients that have all been identified with the same diagnoses. The tricky part here is that this allows the user to select from a slicer the diagnoses for which the user is interested in obtaining a cohort. Identified patients have had diagnoses that meet all of the selected criteria. In other words, all patients have had diagnoses for all of the selected diagnoses in the slicer. Essentially creates an AND for the slicer as opposed to the normal OR.
Cohort =
VAR tmpTable1 = GENERATE(VALUES(Diagnosis[Patient]),
EXCEPT(
VALUES(Diagnosis[Diagnosis]),
CALCULATETABLE(VALUES(Diagnosis[Diagnosis]))))
VAR tmpTable2 = SUMMARIZE(tmpTable1,Diagnosis[Patient])
VAR tmpTable3 = EXCEPT(VALUES(Diagnosis[Patient]),tmpTable2)
RETURN CONCATENATEX(tmpTable3,[Patient],",")
This quick measure would take two inputs, the column for the ID to return (Patient) and the column for the slicer selection (Diagnosis)
Also included is the trivial variation, Count of Cohort:
Count of Cohort = VAR tmpTable1 = GENERATE(VALUES(Diagnosis[Patient]), EXCEPT( VALUES(Diagnosis[Diagnosis]), CALCULATETABLE(VALUES(Diagnosis[Diagnosis])))) VAR tmpTable2 = SUMMARIZE(tmpTable1,Diagnosis[Patient]) VAR tmpTable3 = EXCEPT(VALUES(Diagnosis[Patient]),tmpTable2) RETURN COUNTROWS(tmpTable3)
eyJrIjoiZWYwNzZlNzctOTc5NC00ZWU1LWI2OWMtYTZjYTI0MjIzMjEzIiwidCI6IjRhMDQyNzQzLTM3M2EtNDNkMi04MjdiLTAwM2Y0YzdiYTFlNSIsImMiOjN9
How can we reflect this measure results to all report pages.
For example: we are having WA table in this Id number,option number, option discrimination are the columns.
Id number is unique (99 distinct ID's)
Option number having duplications(767 distinct option numbers)
In option number slicer we need to get AND condition,we will get the result by above example
Here I need to reflect the multiple option number belonging ID number to all the report pages
How can I achieve it
Thank you for directing me to this @Greg_Deckler , it's a very elegant solution.
Picking up on the question from @lherbert501 , How can this be adapted to return a table?
I tried simply returning tmpTable3 as suggested but that didn't seem to work. I also tried using the same code from the measure in a Table definition but that returned a blank. table too. What am I doing wrong?
@KervBruce So to adapt this to return a table, you would implement a Complex Selector. The Complex Selector - Microsoft Fabric Community. The exact solution is going to depend on whether your TagName slicer table is related to your main fact table or coming from your main fact table. Is it or is it a disconnected table?
@Greg_Deckler How could this be amended so that the patient was in a table format?
@lherbert501 Just drop the CONCATENATEX and return tmpTable3 or use the CONCATENATEX with UNICHAR(10) & (UNICHAR(13) as the delimeter.
You may want to try a measure with better performance
Measure =
VAR __cnt = COUNTROWS( ALLSELECTED( Diagnosis[Diagnosis] ) )
RETURN
CONCATENATEX(
FILTER(
VALUES( Diagnosis[Patient] ),
CALCULATE( DISTINCTCOUNT( Diagnosis[Diagnosis] ) ) = __cnt
),
Diagnosis[Patient],
","
)
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@CNENFRNL I'm missing something...