Forum Discussion
Count column value based on multiple criteria in another table
- 2 years ago
Hey ClemFandango ,
as I understand, you want the result as calculated column, is that right?
Try the following calculated column:Count = VAR _DateCurrentRow = Table1[Date] VAR _IDCurrentRow = Table1[ID] VAR _FilterTable2 = FILTER( Table2, [Start] <= _DateCurrentRow && [End] >= _DateCurrentRow && Table2[ID] = _IDCurrentRow) VAR _Result = COUNTROWS( _FilterTable2 ) RETURN _ResultIf you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
Best regards
Denis
Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic - Anonymous2 years ago
Hi, ClemFandango
Maybe you can use the follow DAX :Count = VAR _count=CALCULATE ( COUNT ( 'Table2'[ID] ), FILTER ('Table2', RELATED(Table1[Date]) >= 'Table2'[Start] && RELATED(Table1[Date]) <= 'Table2'[End] && Table2[ID] = [ID] )) RETURN IF(_count> 0, _count, 0)Here is my preview:
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hey ClemFandango ,
as I understand, you want the result as calculated column, is that right?
Try the following calculated column:
Count =
VAR _DateCurrentRow = Table1[Date]
VAR _IDCurrentRow = Table1[ID]
VAR _FilterTable2 = FILTER( Table2, [Start] <= _DateCurrentRow && [End] >= _DateCurrentRow && Table2[ID] = _IDCurrentRow)
VAR _Result = COUNTROWS( _FilterTable2 )
RETURN
_Result
If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
Best regards
Denis
Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic
- ClemFandango2 years ago
Advocate II
This is amazing - thanks so much