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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
ashraf_SISL1
Helper II
Helper II

Count blank in each row of matrix

Hi All,

 

I have below dataset,

Dummy Data.png

 

 

 

 

Where A,B & C are salesman in 1st column.

Where there is no value under sales column, it means salesman didnt woreked on that day.

For example, A didnt worked on 03/05, his total working days would be 3.

Simillarly i want to calcu

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @ashraf_SISL1,

 

Please unpivot the table as below in power query.

Capture.PNG

 

M code for your reference.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI0NASRRsZAEswwVIrViVZyQhYEsY2NwOLOYC1GYNIEqh5EmijFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Salesman = _t, #"5/1/2019" = _t, #"5/2/2019" = _t, #"5/3/2019" = _t, #"5/4/2019" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Salesman", type text}, {"5/1/2019", Int64.Type}, {"5/2/2019", Int64.Type}, {"5/3/2019", Int64.Type}, {"5/4/2019", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Salesman"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"

 

After that, we can create a measure as below and add it to matrix visual.

Measure = 
IF (
    ISFILTERED ( 'Table'[Attribute] ),
    SUM ( 'Table'[Value] ),
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER ( 'Table', 'Table'[Attribute] <> BLANK () )
    )
)

res.PNG

 

Attached the pbix as well.

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

1 REPLY 1
v-frfei-msft
Community Support
Community Support

Hi @ashraf_SISL1,

 

Please unpivot the table as below in power query.

Capture.PNG

 

M code for your reference.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI0NASRRsZAEswwVIrViVZyQhYEsY2NwOLOYC1GYNIEqh5EmijFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Salesman = _t, #"5/1/2019" = _t, #"5/2/2019" = _t, #"5/3/2019" = _t, #"5/4/2019" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Salesman", type text}, {"5/1/2019", Int64.Type}, {"5/2/2019", Int64.Type}, {"5/3/2019", Int64.Type}, {"5/4/2019", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Salesman"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"

 

After that, we can create a measure as below and add it to matrix visual.

Measure = 
IF (
    ISFILTERED ( 'Table'[Attribute] ),
    SUM ( 'Table'[Value] ),
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER ( 'Table', 'Table'[Attribute] <> BLANK () )
    )
)

res.PNG

 

Attached the pbix as well.

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors