Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Roinka
Helper I
Helper I

Changing the filter inside a visualization

Lets say we have several groups of students and we are measuring how many of them had passed the course they participated in successfully (successors). Some of the students belong to a control group and some dont.

We want to draw a simple clustered bar chart (or anything else) which will hold the course name under rows and no_of_successors as values for the non control group students (simple visual level filter in which is_in_control_group=0).

How do we add another row for students in control group?

course a - 5

course b - 10

course c  - 30

control group - 7

Also, how do i display the actual number of successors not only in the tooltip but also in the chart?

Thank you

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

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.

successors.jpg

 

 

View solution in original post

2 REPLIES 2
jdbuchanan71
Super User
Super User

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.

successors.jpg

 

 

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!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors