Forum Discussion
Anonymous
4 years agoNot applicable
Count with two filters
Hi
I want to count if the Production value >0 and filter with the selected month. I wrote a code like below however it counts wrong. (counts 11 however it should be 12)
RunningLines =
var month2 = MONTH(PowerBI[Month]) return
CALCULATE(
COUNT(PowerBI[Production]),FILTER('PowerBI','PowerBI'[Production]>0 && 'PowerBI'[Month]=month2)
//CALCULATE(COUNTROWS((PowerBI)),FILTER(VALUES(PowerBI),PowerBI[Month]=month2),FILTER(VALUES(PowerBI),PowerBI[Production]>0))
)
Machines Production Direct kWh Direct m3 Date Air kW/h Month Other kWh RunningLines
| A5 | 4.117.480 | 67.324 | 58000 | Ocak 2021 | 6.660 | 1 | 15024 | 11 |
| A4 | 2.590.616 | 255.248 | 376000 | Ocak 2021 | 43.174 | 1 | 15024 | 11 |
| A3 | 1.434.620 | 39.588 | 75000 | Ocak 2021 | 8.612 | 1 | 15024 | 11 |
| A2 | 4.141.600 | 81.594 | 172000 | Ocak 2021 | 19.750 | 1 | 15024 | 11 |
| A1 | 6.923.814 | 99.737 | 200000 | Ocak 2021 | 22.965 | 1 | 15024 | 11 |
| P1 | 1.157.356 | 127.054 | 211000 | Ocak 2021 | 24.228 | 1 | 15024 | 11 |
| D15 | 1.447.106 | 98.024 | 95000 | Ocak 2021 | 10.908 | 1 | 15024 | 11 |
| D14 | 1.629.750 | 108.420 | 192000 | Ocak 2021 | 22.046 | 1 | 15024 | 11 |
| D12 | 1.248.672 | 119.557 | 207000 | Ocak 2021 | 23.769 | 1 | 15024 | 11 |
| D11 | 4.938.800 | 50.769 | 120000 | Ocak 2021 | 13.779 | 1 | 15024 | 11 |
| D6 | 0 | 0 | 0 | Ocak 2021 | 0 | 1 | 15024 | 11 |
| D5 | 2.417.926 | 62.466 | 115000 | Ocak 2021 | 13.205 | 1 | 15024 | 11 |
| D4 | 1.667.062 | 26.124 | 68000 | Ocak 2021 | 7.808 | 1 | 15024 | 11 |
Hi,
Try this:RunningLines = var _month = PowerBI[Month] returnCOUNTROWS(FILTER(PowerBI,PowerBI[Production]>0&&PowerBI[Month]=_month),ALL(PowerBI))
Also by including MAX here this will also work as a measure:RunningLines = var _month = MAX(PowerBI[Month]) returnCOUNTROWS(FILTER(PowerBI,PowerBI[Production]>0&&PowerBI[Month]=_month),ALL(PowerBI))
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/
2 Replies
- ValtteriN
Community Champion
Hi,
Try this:RunningLines = var _month = PowerBI[Month] returnCOUNTROWS(FILTER(PowerBI,PowerBI[Production]>0&&PowerBI[Month]=_month),ALL(PowerBI))
Also by including MAX here this will also work as a measure:RunningLines = var _month = MAX(PowerBI[Month]) returnCOUNTROWS(FILTER(PowerBI,PowerBI[Production]>0&&PowerBI[Month]=_month),ALL(PowerBI))
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/ - AnonymousNot applicable
Hi ValtterİN
I copied two of the code and ALL(PowerBI) showed errors I just deleted it and it works.
thank you a lot
RunningLines =var _month = PowerBI[Month] returnCOUNTROWS(FILTER(PowerBI,PowerBI[Production]>0&&PowerBI[Month]=_month))