Forum Discussion
Get count per timestamp for each ID
- 5 years ago
Yes datanau001 - one of the few times a column is better than a slicer. Slight tweak to my measure:
Item Count = VAR varCurrentValue = 'Table'[Item] VAR Result = CALCULATE( COUNTROWS('Table'), 'Table'[Item] = varCurrentValue, REMOVEFILTERS('Table') ) RETURN COALESCE(Result,0)Strictly speaking the COALESCE() at the end isn't necessary as you'd never have a blank like this in a column, but I am just in the habit of using it with any measure that has COUNTROWS() so I get a true 0 vs <BLANK>
You could just use "Result" at the end after the RETURN statement.
Try this datanau001 - note: this is a measure, not a column. Measures are best practices.
Item Record Count =
VAR varCurrentValue = MAX('Table'[Item])
VAR Result =
CALCULATE(
COUNTROWS('Table'),
'Table'[Item] = varCurrentValue,
REMOVEFILTERS('Table')
)
RETURN
COALESCE(Result,0)
If you need further help, please give us some data to work with. Cannot use images to paste into Power BI.
How to get good help fast. Help us help you.
How To Ask A Technical Question If you Really Want An Answer
How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.
- datanau0015 years ago
Helper III
Hello Edhans,
Thank you for your quick reply.
Your suggestion works, however, I can't use it as a slicer.
What would be a similar solution but that could be used as a slicer?
Br//
Marcelo
- edhans5 years ago
Community Champion
Yes datanau001 - one of the few times a column is better than a slicer. Slight tweak to my measure:
Item Count = VAR varCurrentValue = 'Table'[Item] VAR Result = CALCULATE( COUNTROWS('Table'), 'Table'[Item] = varCurrentValue, REMOVEFILTERS('Table') ) RETURN COALESCE(Result,0)Strictly speaking the COALESCE() at the end isn't necessary as you'd never have a blank like this in a column, but I am just in the habit of using it with any measure that has COUNTROWS() so I get a true 0 vs <BLANK>
You could just use "Result" at the end after the RETURN statement.- datanau0015 years ago
Helper III
Hello Edhans,
Exactly what I was looking for.
Thank you very much for the support.
Regards
Marcelo