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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Pivotable78
New Member

CountIF by rows in multiple columns on powerquery

Hi,

 

I'm struglling to find solution to do this in power query and didn't find here :

I get a report from salesforces that shows activity by sales reps by day that i load on power query.

 

it looks like this (without red columns) :

 

RepMondayTuesdayWednesdayThursdayFridayDate
On fieldout of field
Name AOn fieldOn fieldOn fieldout of fieldout of fieldNovember
32
Name BOn fieldout of fieldout of fieldout of fieldout of fieldNovember
1

4

Name AOn fieldOn fieldOn fieldOn fieldOn fieldDecember
5

0

 

What I want is to sum for each month the number of values "On field" and "out of field"  like the red columns then fill another file with xlookup.

 

 

Thank you for your help🙏

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

Hi @Pivotable78 ,

According to your description, here's my solution.

1. In Power Query, select the columns "Monday, Tuesday, Wednesday, Thursday, Friday" (Ctrl+select).

vkalyjmsft_0-1643337726663.png

2. Click "Unpivot Columns" tab under the Transform ribbon.

vkalyjmsft_1-1643337794452.png

Get this table.

vkalyjmsft_2-1643337971502.png

3.Create two measures.

Count on field =
CALCULATE (
    COUNT ( 'Table'[Value] ),
    ALLEXCEPT ( 'Table', 'Table'[Rep], 'Table'[Month] ),
    'Table'[Value] = "On field"
)
Count out field =
CALCULATE (
    COUNT ( 'Table'[Value] ),
    ALLEXCEPT ( 'Table', 'Table'[Rep], 'Table'[Month] ),
    'Table'[Value] = "Out of field"
) + 0

Get the result.

vkalyjmsft_3-1643338179335.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

 

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

3 REPLIES 3
Pivotable78
New Member

Hi,

 

It worked thanks for your help.

v-yanjiang-msft
Community Support
Community Support

Hi @Pivotable78 ,

According to your description, here's my solution.

1. In Power Query, select the columns "Monday, Tuesday, Wednesday, Thursday, Friday" (Ctrl+select).

vkalyjmsft_0-1643337726663.png

2. Click "Unpivot Columns" tab under the Transform ribbon.

vkalyjmsft_1-1643337794452.png

Get this table.

vkalyjmsft_2-1643337971502.png

3.Create two measures.

Count on field =
CALCULATE (
    COUNT ( 'Table'[Value] ),
    ALLEXCEPT ( 'Table', 'Table'[Rep], 'Table'[Month] ),
    'Table'[Value] = "On field"
)
Count out field =
CALCULATE (
    COUNT ( 'Table'[Value] ),
    ALLEXCEPT ( 'Table', 'Table'[Rep], 'Table'[Month] ),
    'Table'[Value] = "Out of field"
) + 0

Get the result.

vkalyjmsft_3-1643338179335.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

 

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

Hi

 

I will check that 😉

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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