Forum Discussion
count rows with some conditions
Hi johnt75 ,
thank you very much answer but the measure result is blank, did you tested?
Yes, if I put that measure on a table or matrix visual with idticket and idclient on the rows then I get correct values.
Do you have any other filters applied which could restrict the results ?
- Anonymous4 years agoNot applicable
No, I don't have any filters that restrict the results. I need this measure on a card but the result of that measure is blank. In the matrix the total that you see is blank and for that reason on the card is blank too.
In the future, I will only have a filter that is in the date table "interval" to see which tickets belong to each interval.
Your solution seems so elegant and nice but for the moment doesn't work for this purpose :/.- johnt754 years ago
Super User
I understand, you want the overall total not broken down by client / ticket.
Num occurrences = SUMX( ADDCOLUMNS( SUMMARIZE( 'Table', 'Table'[idclient], 'Table'[idticket], 'Table'[Date_time] ),
"@value",
var currentClient = CALCULATE( SELECTEDVALUE( 'Table'[idclient] ) )
var currentTicket = CALCULATE( SELECTEDVALUE( 'Table'[idticket] ) )
var minDate = CALCULATE( MIN('Table'[Date_time]), 'Table'[idclient] = currentClient && 'Table'[idticket] = currentTicket )
var result = COUNTROWS( SUMMARIZE(
FILTER( 'Table', 'Table'[idclient] = currentClient && 'Table'[idticket] = currentTicket && 'Table'[Date_time] > minDate ),
'Table'[idclient], 'Table'[idticket], 'Table'[Date_time]
) )
return result
), [@value])should give you what you're after
- Anonymous4 years agoNot applicable
Thank you again for your answer! There is another problem that I forgot to mention. When you select a filter like for instance month, in your formula the first result is not considered even it is the same occurrence from the previous month.
About your new formula, the result for idclient 001 is 55 and should be 10 and If you filter august should be 5. PBi file https://1drv.ms/u/s!AuMLcKZkL7PFgkY3qjc2GJ35giM2?e=MAcPtQ
thank you again for your time.