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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
darpao
New Member

Multiple response and filters

I have a survey that generate 2 tables, one main table like this (Main):

 

IDYearCountry
12018UK
22019USA
32019USA
42020Germany
52020USA
62018Germany

 

and another derived from a multiple response like this (Tecahnology):

 

IDTechnology
1A
1B
2B
3A
3C
3D
4C
5B
5C
5D
6A

 

Now in a page I have 3 filters, one compulsory and another 2 optionals:

 

technology - must be A, B, C, or D (only one of this, single choice)

year - could be void or could be one or more out of 2018, 2019, 2020

country - like year, is not necessary to get it

 

and I want a summary table with this data:

 

Filter on A

 

YearPercentage
2018=2/2 -> 100% because both 1 and 6 have technology A
2019=1/2 -> 50% because only 3 has technology A and not 2
2020=0/2 -> 0% because neither 4 or 5 have technology A

 

I'm not able to get the 2 of the denominator. I have tried CALCULATE with COUNTROWS, ALLSELECTED, ALLCROSSFILTER and so on, but nothing.

 

When then I filter also, for example country USA, the table should update like this:

 

Filter on A and USA

 

YearPercentage
2018=0/0 -> 0% because both 1 and 6 are not in USA
2019=1/2 -> 50% it remains like the previous table, because both 2 and 3 are in USA
2020=0/1 -> 0% denominator change to 1 because only 5 is in USA

 

 

Any helps?

I'm stucked with it from days.

 

Thank you

1 ACCEPTED SOLUTION

Finally I was able to find the solution.

Thank you @ERD because your code helped me.

 

This is what I was looking for:

 

#Percentage = VAR main_id = CALCULATE(COUNTROWS('T-main'),REMOVEFILTERS('T-tech'[Technology]))
VAR tech_id = COUNT('T-tech'[ID])
VAR percentage = tech_id / main_id
RETURN
COALESCE(percentage,0)

View solution in original post

4 REPLIES 4
ERD
Super User
Super User

Hi @darpao ,

I suppose your tables are connected via ID column. You can try this measure:

#Percentage = 
VAR main_id = COUNT('T-main'[ID])
VAR tech_id = CALCULATE(COUNT('T-tech'[ID]))
VAR percentage = tech_id / main_id
RETURN 
COALESCE(percentage,0)

ERD_0-1622132867002.png

If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Thank you @ERD ,

I still get all 1 in the table, like dividing the same amount.

Did you forget the second argument of calculate function in tech_id variable, maybe?

 

Can you attach the PBIX attemps that you did?

@darpao ,

I'm not sure what do you mean. You can check what you get by separating the measure:

#tech_id = CALCULATE(COUNT('T-tech'[ID]))
#main_id = COUNT('T-main'[ID])

ERD_0-1622182445356.png

If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Finally I was able to find the solution.

Thank you @ERD because your code helped me.

 

This is what I was looking for:

 

#Percentage = VAR main_id = CALCULATE(COUNTROWS('T-main'),REMOVEFILTERS('T-tech'[Technology]))
VAR tech_id = COUNT('T-tech'[ID])
VAR percentage = tech_id / main_id
RETURN
COALESCE(percentage,0)

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.