Forum Discussion
Count rows with same value in one column
I'm assuming it's intended that you want the dates to display multiple times as well in the visual. This would typically mean either
a) you're not using a date table or
b) there are going to be more columns added to the display table and a date table is going to be used.
Either way, the following calculation should do the job for you. 'Table' in this case is going to be the table that your fact is (I.E. not the date table)
CountOfDates =
var _SelectedValueDate = SELECTEDVALUE('Table'[Date])
return
CALCULATE(
COUNTROWS('Table'),
ALL('Table'),
'Table'[Date] = _SelectedValueDate
)- Shota_Xuc2 years agoHelper I
Hi NickDanger, it does not work. E.g. I should get 3 for 02-06, 1 for 02-09, 2 for 02-13 instead.
I think the expression takes numbers from ground table my visual is based on, but rows in my visual are filtered out. I need to count rows with the same valuation date on my visual below.
- NickDanger2 years agoRegular Visitor
Shota_Xuc
Thanks for the elaboration. The original post did have much info. Here is a code snippest of test data from AdventureWorks that I mocked up that would work with your issue.Test Measure = var _SelectedValueDate = SELECTEDVALUE('FactInternetSales'[OrderDate]) RETURN CALCULATE( COUNTROWS('FactInternetSales'), ALLEXCEPT('FactInternetSales', 'FactInternetSales'[PromotionKey]), //Add any columns here that you're filtering on 'FactInternetSales'[OrderDate] = _SelectedValueDate)Include any of the columns you're filtering your table on in the ALLEXCEPT function. For instance, in my data I filtered on PromotionKey.
This first screenshot is without including PromotionKey in the ALLEXCEPT, the second screenshot is when it's written to account for the filter.- Shota_Xuc2 years agoHelper I
it does not work, I have adjusted your code to my visual, here is my code:
Test Measure =var _SelectedValueDate = SELECTEDVALUE('SFX_TRS_RESET_MATURITY_DATES'[Valuation date])RETURNCALCULATE(COUNTROWS('SFX_TRS_RESET_MATURITY_DATES'),ALL('SFX_TRS_RESET_MATURITY_DATES'), //Add any columns here that you're filtering on'SFX_TRS_RESET_MATURITY_DATES'[Valuation date] = _SelectedValueDate)and I get wrong numbers: