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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
ez1138
Frequent Visitor

Adding Column Data, Based on Text

Hi, I would like to calculate the total # of results for a given row/person for pass or fail.  What is the based way to perform this and display in a new column and potentially a tile?

 

PersonTest 1Test 2Test 3Test 4
AdamPassPassFailPass
JohnPassFailPassPass
JoeFailPassFailFail
1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @ez1138 

 

According to your description, I think you can use'unpivot other columns' function in PQ first, then create a measure to display your desired result.

Like this:

Measure = 
SUMX (
    SUMMARIZE (
        'Table',
        'Table'[Person],
        'Table'[Value],
        "a",
            VAR a =
                COUNTROWS ( FILTER ( 'Table', [Value] = "Fail" ) )
            VAR b =
                COUNTROWS ( FILTER ( 'Table', [Value] = "Pass" ) )
            RETURN
                IF ( SELECTEDVALUE ( 'Table'[Value] ) = "Pass", b, a )
    ),
    [a]
)

1.png2.png

Here is my sample .pbix file.Hope it helps.

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

View solution in original post

2 REPLIES 2
v-janeyg-msft
Community Support
Community Support

Hi, @ez1138 

 

According to your description, I think you can use'unpivot other columns' function in PQ first, then create a measure to display your desired result.

Like this:

Measure = 
SUMX (
    SUMMARIZE (
        'Table',
        'Table'[Person],
        'Table'[Value],
        "a",
            VAR a =
                COUNTROWS ( FILTER ( 'Table', [Value] = "Fail" ) )
            VAR b =
                COUNTROWS ( FILTER ( 'Table', [Value] = "Pass" ) )
            RETURN
                IF ( SELECTEDVALUE ( 'Table'[Value] ) = "Pass", b, a )
    ),
    [a]
)

1.png2.png

Here is my sample .pbix file.Hope it helps.

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

lbendlin
Super User
Super User

The process is called unpivoting - transforming your source data into usable format.

 

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckxJzFXSUQpILC5GUG6JmTkwXqxOtJJXfkYedlkURakYklAemIqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Person = _t, #"Test 1" = _t, #"Test 2" = _t, #"Test 3" = _t, #"Test 4" = _t]),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Person"}, "Attribute", "Value")
in
#"Unpivoted Other Columns"

 

 

lbendlin_0-1612574910267.png

 

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.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

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 Kudoed Authors