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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
NewLearner555
New Member

Need help on how to filter and divide column for a percentage

Hello,

Normally when I do a table for a percentage I use the following formula to get a percentage.

 

measure= DIVIDE(COUNT('Q2'[Black.Vancover]),CALCULATE(COUNT('Q2[Black.Vancover]),ALLSELECTED()))

 

The example table is below:

Table would be called for this example Q2

ID MarkerDo you like milk?Black.Vancover
100Yes1
101Nonull
10564Yesnull
1687Yesnull
10006No1
6804Yes1

 

This table is created by merging two tables together using the unique ID Marker. In the example respondants who were Black and in Vancover was merged with the table with the question and answers. This allows me to make measures with the formula above to get a percentage to use in graphs. I compare the different groups together by making seperate tables and the relationship between them is the answers. (I make a seperate table ex below, that has a relationship with the different tables for the different groups I am comparing in a graph)

OrderAnswer
1Yes
2No

 

Now my problem is I have a question that I need to graph that is essential 4 questions being asked.

The example below only is showing two questions, but what I am trying to do, is somehow in a measure filter the information so I am only getting a percentage for the question "Do you like milk", instead of a percentage for both "Do you like milk" and "Do you like cheese?"

 

ID MarkerQuestionAnswerBlack.VancoverSouth Asian.Vancover
100Do you like milk?Yesnull1
101Do you like cheese?No1null
102Do you like cheese?Nonull1
103Do you like cheese?Yes1null
104Do you like milk?Yes1null

 

Does anyone know a solution to this problem? I cannot figure out the filter function with this formula.
5 REPLIES 5
v-zhengdxu-msft
Community Support
Community Support

Hi @NewLearner555 

 

I've known your issue, maybe you can try filter function:

I create a set of sample data:

vzhengdxumsft_0-1707796509000.png

 

Then create a calculate column:

 

Column = IF(
        'Table (2)'[week]=1,
        CALCULATE(
            COUNTROWS('Table (2)'),
            FILTER(
                ALLSELECTED('Table (2)'),
                'Table (2)'[week]=1
            )
        )
    )

 

The result is as follow:

vzhengdxumsft_1-1707796614054.png

 

Best Regards,

Zhengdong Xu

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

When I tried this calculation but it returns as an error. The If statement is asking for a measure instead of the columns in my table.

I did edit my question and made some example tables.

Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

I changed the information in the screenshot I provided so there was no sensitive data, but I've fixed the post like in the link you provided and hopefully made the problem more clear.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Kudoed Authors