Forum Discussion
Count in two related tables
- Anonymous9 years ago
If you drag a Matrix visual to your canvas, with ID in Rows, and the measure totalTAreas in Values, I think it will give you the result you need.
Or you can add a column as described by Baskar, though I can't see from your requirements why it must be a column.
Note that columns can't be used is some situations (e.g. axis on a scatter plot), measures are generally more efficient, but measures can't be used as slicers.
Since you have related the two tables, the following measure (not column) should do what you need:
totalTareas = COUNT( table2[TASK] )
For some guidance on measures vs columns, check the following links which I 've found useful:
http://exceleratorbi.com.au/calculated-columns-vs-measures-dax/
https://www.sqlbi.com/tv/dax-calculated-columns-vs-measures/
- hector33159 years agoFrequent Visitor
No, i explained myself in a bad way i need to print table 1 and i want the count of all the tasks each id has. Not a global count, that is why i need that column i cheked the links and are nice but in this case i need the calculated colum.
Thanks for the information about measures and columns i found it interesting :)
- Baskar9 years ago
Resident Rockstar
1. create relationship between these two table.
2. Create calculated column on Table 1
Column =Calculate( COUNTROWS(RELATEDTABLE('Table 2')))
am sure it will help u, if not let me know i will help u my friend .
- hector33159 years agoFrequent Visitor
The second solution doesn't work. I go to investigate that CALCULATE. i think that is the solution to my problem
- Anonymous9 years agoNot applicable
If you drag a Matrix visual to your canvas, with ID in Rows, and the measure totalTAreas in Values, I think it will give you the result you need.
Or you can add a column as described by Baskar, though I can't see from your requirements why it must be a column.
Note that columns can't be used is some situations (e.g. axis on a scatter plot), measures are generally more efficient, but measures can't be used as slicers.
- hector33159 years agoFrequent Visitor
That works so fine man !!
I didn't know that measures could be used to get values by row I thougth that they were only to get one value.
I have just seen the video and now I understand how a measure works. And yes it is more efficient than calculated columns by far.
I found a bad way to do it duplicating the table and grouping by id but that is so unefficient.
A lot of thanks to both and sorry cause the answer was here from the first message but i didn't know how to apply it. Sometimes it is better no to run a lot and take time to see the things clare. :smileyhappy: