Forum Discussion
Changing the filter inside a visualization
- 7 years ago
Hello Roinka ,
I have attached my sample .pbix file for you to look at.
First I created a measure just for ordering the course names in my calculated table so I could force "Control" to the end.
CourseRow = VAR Course = SELECTEDVALUE(Results[Course]) RETURN CALCULATE(COUNTROWS(VALUES(Results[Course])),FILTER(ALL(Results[Course]),Results[Course]<Course))+1
Then a calculated table so we have somewhere to have "Control" along with the courses.
Courses = UNION ( ADDCOLUMNS ( DISTINCT(Results[Course]),"Order",[CourseRow]), ROW("Course","Control","Order",99) )You want to make sure to sort the Courses in this table by the [Order] column.
Next the measure to do the counting.
Successors = VAR Succesors = CALCULATE(DISTINCTCOUNT(Results[Student]),Results[Successor]= 1, Results[in_control_group] = 0) VAR InControl = CALCULATE(DISTINCTCOUNT(Results[Student]),ALL(Results),Results[in_control_group] = 1) RETURN IF ( SELECTEDVALUE(Courses[Course]) = "Control", InControl,Succesors)
Which we put in the chart along with the [Course] from our calculated table and you can show the number in the chart by turning the data labels on.
Hello Roinka ,
I have attached my sample .pbix file for you to look at.
First I created a measure just for ordering the course names in my calculated table so I could force "Control" to the end.
CourseRow = VAR Course = SELECTEDVALUE(Results[Course]) RETURN CALCULATE(COUNTROWS(VALUES(Results[Course])),FILTER(ALL(Results[Course]),Results[Course]<Course))+1
Then a calculated table so we have somewhere to have "Control" along with the courses.
Courses =
UNION (
ADDCOLUMNS ( DISTINCT(Results[Course]),"Order",[CourseRow]),
ROW("Course","Control","Order",99)
)
You want to make sure to sort the Courses in this table by the [Order] column.
Next the measure to do the counting.
Successors = VAR Succesors = CALCULATE(DISTINCTCOUNT(Results[Student]),Results[Successor]= 1, Results[in_control_group] = 0) VAR InControl = CALCULATE(DISTINCTCOUNT(Results[Student]),ALL(Results),Results[in_control_group] = 1) RETURN IF ( SELECTEDVALUE(Courses[Course]) = "Control", InControl,Succesors)
Which we put in the chart along with the [Course] from our calculated table and you can show the number in the chart by turning the data labels on.
- Roinka7 years agoHelper I
Thank you very much. I have used your idea but with less DAX.
What i did is to add a conditional column to hold either "Control" if the student belongs to the control group or the Course Name otherwise.
Than i have created the chart where the new column will be in rows (rows will either contain course name or the word Control) and number of successors in values.
This is based over what you have showed.
Thank you!