Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon'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.
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 | DOC | ContributionAmount |
101 | 1/15/2023 | 100 |
101 | 3/12/2023 | 200 |
101 | 1/18/2024 | 150 |
102 | 2/20/2024 | 300 |
102 | 3/25/2024 | 250 |
102 | 2/15/2023 | 200 |
102 | 3/15/2023 | 150 |
102 | 3/14/2023 | 0 |
102 | 5/23/2023 | 4 |
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.
UserID | ContYear | Total Contribution | No of Contributions |
101 | 2023 | 300 | 2 |
101 | 2024 | 150 | 1 |
102 | 2023 | 354 | 3 |
102 | 2024 | 550 | 2 |
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.
Solved! Go to Solution.
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:
Helpful. Thank you very much!
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:
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
105 | |
75 | |
43 | |
39 | |
32 |
User | Count |
---|---|
170 | |
90 | |
65 | |
46 | |
44 |