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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Giovani
Helper I
Helper I

Percent of column total

I am relatively new in PowerBI and I am trying to solve an issue based on the data below:

ID

Result

Date

1

Negative

1/1/17

1

Inconclusive

1/1/17

1

Positive

1/1/17

1

Suspect

1/1/17

1

Positive

1/1/17

2

Positive

2/2/17

2

Positive

2/2/17

2

Negative

2/2/17

2

Negative

2/2/17

3

Negative

4/2/17

3

Suspect

4/2/17

3

Negative

4/2/17

4

Positive

4/3/17

4

Positive

4/3/17

4

Positive

4/3/17

5

Negative

6/17/17

5

Negative

6/17/17

5

Negative

6/17/17

5

Suspect

6/17/17

5

Negative

6/17/17


I am trying to build percentage results based on the ID column considering that: 

1- if for one ID has one result positive that will consider the ID like positive and do not count for the other results. If there are no positive case and one suspect result count as 

2 - If there is no positive case, but one suspect result counts as suspect and do not count the others.

3- If there are no positive or suspect, but Inconclusive should count as Inconclusive.

4 - If only negative is related with the ID count as negative.

 

 

When I try to calculate the results are counted more than once for each ID. And at the end, I have more results than the total of ID`s.

Besides of that, I want to build a graph taking the timeline in the x-axis.

 

Any thoughts how can I solve this?

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

Hi @Giovani,

 

If I understand you correctly, you can use the formula below to create a new calculate column in your table to get the actual Result for each ID based on considerations mentioned above.

Actual Result = 
VAR positives =
    CALCULATE (
        COUNTA ( Table1[Result] ),
        FILTER ( ALLEXCEPT ( Table1, Table1[ID] ), Table1[Result] = "Positive" )
    )
VAR suspects =
    CALCULATE (
        COUNTA ( Table1[Result] ),
        FILTER ( ALLEXCEPT ( Table1, Table1[ID] ), Table1[Result] = "Suspect" )
    )
VAR inconclusives =
    CALCULATE (
        COUNTA ( Table1[Result] ),
        FILTER ( ALLEXCEPT ( Table1, Table1[ID] ), Table1[Result] = "Inconclusive" )
    )
VAR negatives =
    CALCULATE (
        COUNTA ( Table1[Result] ),
        FILTER ( ALLEXCEPT ( Table1, Table1[ID] ), Table1[Result] = "Negative" )
    )
RETURN
    IF (
        positives >= 1,
        "Positive",
        IF (
            suspects >= 1,
            "Suspect",
            IF ( inconclusives >= 1, "Inconclusive", IF ( negatives >= 1, "Negative" ) )
        )
    )

c2.PNG

 

Then you should be able to use the "Actual Result" column to easily get the expected result in your scenario. Smiley Happy

 

Regards

View solution in original post

3 REPLIES 3
v-ljerr-msft
Employee
Employee

Hi @Giovani,

 

If I understand you correctly, you can use the formula below to create a new calculate column in your table to get the actual Result for each ID based on considerations mentioned above.

Actual Result = 
VAR positives =
    CALCULATE (
        COUNTA ( Table1[Result] ),
        FILTER ( ALLEXCEPT ( Table1, Table1[ID] ), Table1[Result] = "Positive" )
    )
VAR suspects =
    CALCULATE (
        COUNTA ( Table1[Result] ),
        FILTER ( ALLEXCEPT ( Table1, Table1[ID] ), Table1[Result] = "Suspect" )
    )
VAR inconclusives =
    CALCULATE (
        COUNTA ( Table1[Result] ),
        FILTER ( ALLEXCEPT ( Table1, Table1[ID] ), Table1[Result] = "Inconclusive" )
    )
VAR negatives =
    CALCULATE (
        COUNTA ( Table1[Result] ),
        FILTER ( ALLEXCEPT ( Table1, Table1[ID] ), Table1[Result] = "Negative" )
    )
RETURN
    IF (
        positives >= 1,
        "Positive",
        IF (
            suspects >= 1,
            "Suspect",
            IF ( inconclusives >= 1, "Inconclusive", IF ( negatives >= 1, "Negative" ) )
        )
    )

c2.PNG

 

Then you should be able to use the "Actual Result" column to easily get the expected result in your scenario. Smiley Happy

 

Regards

Thanks a lot, v-ljerr-msft  !!!!!!!!!!!

That code solved my issue.

Ashish_Mathur
Super User
Super User

Hi,

 

What final results are you expecting?  Show those numbers and method of arriving at those numbers.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.