Forum Discussion
SteffenSchulze
4 years agoNew Member
DAX: Counting multiple values in different columsn
Hi, I have a table with disinct list of entities. Each entitiy is represented by two more columns which each describe a year. This is what the table basically looks like: Entity Year1 ...
- 4 years ago
Try this code to add a new table with DAX:
Table 2 = VAR _A = VALUES ( 'Table'[Year1] ) VAR _B = EXCEPT ( VALUES ( 'Table'[Year2] ), _A ) VAR _C = SELECTCOLUMNS ( UNION ( _A, _B ), "Year", [Year1] ) RETURN ADDCOLUMNS ( _C, "Year1", CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', 'Table'[Year1] = EARLIER ( [Year] ) ) ) + 0, "Year2", CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', 'Table'[Year2] = EARLIER ( [Year] ) ) ) + 0 )Output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
SteffenSchulze
4 years agoNew Member
Yes, I do have a separate table with year.
smpa01
Community Champion
4 years agoSteffenSchulze spare more deatils? Are those two tables related? How?