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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
claw25
New Member

Count rows where value is greater than 0 for every user for every year

I'm new to power bi. I'm trying to learn it very quickly but having trouble counting where a value is greater than zero.

I have a data set that looks like this.

 

UserID      DOCContributionAmount
1011/15/2023100
1013/12/2023200
1011/18/2024150
1022/20/2024300
1023/25/2024250
1022/15/2023200
1023/15/2023150
1023/14/20230
1025/23/20234

 

I'm trying to sum the ContributionAmount and also show the number of contributions for each user for every year. I only want to increase the No of contributions if the contribution amount is greater than 0. So user 102 would have only 3 contributions for the year 2023. So in essence I'm trying to create a table that looks like this.

 

UserIDContYearTotal ContributionNo of Contributions
10120233002
10120241501
10220233543
10220245502

 

I think this should be easy but haven't had much luck. Greatful if someone can point me in the right direction of a solution or resources to find the best solution.

1 ACCEPTED SOLUTION
Bibiano_Geraldo
Super User
Super User

Hi @claw25 ,
1-Create a new column for the year:

ContYear = YEAR('Table'[DOC])

2- now create a measure for Total Contribution

Total Contribution = 
SUM('Table'[ContributionAmount])

3- Create a measure for No of Contributions

No of Contributions = 
CALCULATE(
    COUNTROWS('Table'),
    'Table'[ContributionAmount] > 0
)

now you can add UserID, ContYear, Total Contribution, and No of Contributions to the table visual, your table should look like this:

Bibiano_Geraldo_0-1737498931429.png

 

I hope this helps! 
If you found this answer helpful:
✔️ Mark it as the solution to help others find it faster.
 Give it a like to show your appreciation!

Thank you for contributing to our amazing Power BI community! 

View solution in original post

2 REPLIES 2
claw25
New Member

Helpful. Thank you very much!

Bibiano_Geraldo
Super User
Super User

Hi @claw25 ,
1-Create a new column for the year:

ContYear = YEAR('Table'[DOC])

2- now create a measure for Total Contribution

Total Contribution = 
SUM('Table'[ContributionAmount])

3- Create a measure for No of Contributions

No of Contributions = 
CALCULATE(
    COUNTROWS('Table'),
    'Table'[ContributionAmount] > 0
)

now you can add UserID, ContYear, Total Contribution, and No of Contributions to the table visual, your table should look like this:

Bibiano_Geraldo_0-1737498931429.png

 

I hope this helps! 
If you found this answer helpful:
✔️ Mark it as the solution to help others find it faster.
 Give it a like to show your appreciation!

Thank you for contributing to our amazing Power BI community! 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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