Forum Discussion
Refer to calculated table
- 3 years ago
Hi Anonymous,
This is long overdue but I finally found the solution.
The measure that eventually worked is:AGE GROUPS per BIODAYMED = VAR x = CALCULATETABLE ( ADDCOLUMNS( SUMMARIZE ( factAnswer, factAnswer[Participant_GUID], factAnswer[Form_Instance_ID] ) ,"BirthYear", DATE ( CALCULATE ( MIN ( factAnswer[AnswerNumeric] ), dimMetadata[Field_Variable_Name] = "Birth_Year", ALL ( factAnswer[Form_Instance_ID] ) ), 1, 1 ), "VisitDate", CALCULATE ( MIN ( factAnswer[AnswerDateDate] ), dimMetadata[Field_Variable_Name] = "Visit_Date" ), "VisitType", CALCULATE ( MIN ( factAnswer[Answer] ), dimMetadata[Field_Variable_Name] = "Visit_Type" ), "AgeAtVisit", DATEDIFF ( DATE ( CALCULATE ( MIN ( factAnswer[AnswerNumeric] ), dimMetadata[Field_Variable_Name] = "Birth_Year", ALL ( factAnswer[Form_Instance_ID] ) ), 1, 1 ), CALCULATE ( MIN ( factAnswer[AnswerDateDate] ), dimMetadata[Field_Variable_Name] = "Visit_Date" ), YEAR ), "Medication", CALCULATE ( MIN ( factAnswer[Answer] ), dimMetadata[Field_Variable_Name] = "BioDayMed_Type" ) ) ) VAR MinAge = SELECTEDVALUE(AddCategories[From],0.01) VAR MaxAge = SELECTEDVALUE(AddCategories[To],150) VAR Med = CONVERT(SELECTEDVALUE(WhatIf[Value]),STRING) VAR VisitType = "0" VAR CountMedAgeGroup = COUNTX ( FILTER (x, [AgeAtVisit]>=MinAge && [AgeAtVisit]<=MaxAge && [Medication] = Med && [VisitType] = VisitType ), [Form_Instance_ID] ) VAR NoSelectedMed = COUNTX ( FILTER (x, [AgeAtVisit]>=MinAge && [AgeAtVisit]<=MaxAge && [VisitType] = VisitType ), [Form_Instance_ID] ) RETURN IF(Med=BLANK(), NoSelectedMed, CountMedAgeGroup)
Hi MariekevdAkker ,
I tried to update the formula of the measure [AgeGroups BL] using the formula in my previous post, it works welll. Please find the details in the screenshot below. Is there anything else I missing here?
Best Regards
Hi Anonymous ,
Thank you again for your time to help me.
In the example dataset I get the same results as you, however it should not reply only adults (18+), there are children in the selection. It apears to ignore the filter and uses the overall MAX of all the birth_years.
Furthermore, If I use the exact same measure on my actual model which has a live connection to an analysis server I get the following error:
"Calculation error in measure 'MeasureTable'[AgeGroups BL]: A function 'MAXX' has been used in a True/False expression that is used as a table filter expression. This is not allowed."
I can also generate the error in the example dataset by adding a calculate around the MAXX function.
Kind Regards,
Marieke