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
DanC
Frequent Visitor

Countrows Function with subsequent cell/Row value part of the criteria

Hi

My query is that i am used to working with excel and COUNTIFS where one of the tables values in each row is part of the criteria, so when you drag down the formula, the criteria is constantly changing depending on the cell value of the current row.

 

Now in PBI i have an expression 'Year 1 Callouts = CALCULATE(COUNTROWS(incidents),FILTER(incidents,incidents[Year of Life of Machine on Visit]="Year 01"),FILTER(incidents,incidents[Case Type]="Engineer Callout"),FILTER(incidents,incidents[Status Reason]="Job Complete"))'

 

This partly works as it totals the rows based on the criteria, but of course all the subsequent rows give the same total, and i want it the final criteria to be based on a specific row field that matches in my COUNTROWS table,

Can anyone help with the part of the criteria that i am missing?

5 REPLIES 5
Zubair_Muhammad
Community Champion
Community Champion

HI @DanC

 

What is that specific row field?

 

If you use that field with earlier function you will hopefully get correct results

 

 


Regards
Zubair

Please try my custom visuals

@DanC

 

Try this. Just replace "That_Specific_Field" with the actual field name

 

Year 1 Callouts =
CALCULATE (
    COUNTROWS ( incidents ),
    FILTER (
        ALLEXCEPT ( incidents, Incidents[That_Specific_Field] ),
        incidents[Year of Life of Machine on Visit] = "Year 01"
            && incidents[Case Type] = "Engineer Callout"
            && incidents[Status Reason] = "Job Complete"
    )
)

Regards
Zubair

Please try my custom visuals
jthomson
Solution Sage
Solution Sage

I'm not sure what you're trying to do here, is there another criteria that you're wanting to add on if something matches year 1/engineer callout/job complete?

 

I'm also not sure why you're using the filter function as part of that expression?

DanC
Frequent Visitor

yes the final criteria i am trying to add is where it matches the row data from one table with all the row data from the second table, so in excel it would be an 'IF' or 'COUNTIF' statement and the column header i'm trying to match is called "_new_assetid_value" from the 'incidents' table

DanC
Frequent Visitor

Thanks for replying jtomson,

Yes i am trying to add another function as part of the lookup criteria, all the other criteria i have in the expression are using a text based lookup, i.e. count the amount of rows where the text "Yr 01" appears in a certain column, that works fine.

 

What i want to add as part of the lookup formula is if whatever appears in one row of a column of data of the first table, matches whatever appears in another another row of a column in my second to table. So it adds to part of the lookup criteria

 

Regards

Dan

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.