How do I count rows in one table based on values in another table using DAX

0 votes

What I am trying to accomplish is to calculate the number of times that value appears in Table2 as a new column in Table1. How do I count rows in one table based on values in another table using DAX

Sep 24, 2020 in Power BI by anonymous
• 10,400 points
1,752 views

1 answer to this question.

0 votes

If the tables are related, this is very simple, you can see the below-given suggestion:

Number of Table2 rows = COUNTROWS(RELATEDTABLE(Table2))

Then you can add a Calculated Column to Table1 which counts the times each item appears in Table2:

Number of Table 2 rows: COUNTROWS(RELATEDTABALE(Table2))

If the tables are not related, you can use CALCULATE and FILTER:

Number of Table2 rows =
CALCULATE(
    COUNTROWS(Table2),
    FILTER(
        Table2,
        Table2[Column1] = Table1[Column1]
    )
)
answered Sep 24, 2020 by Gitika
• 65,850 points

Related Questions In Power BI

0 votes
1 answer

How do I label bar graph with different colors based on values from different slicers?

If the user selects only one value ...READ MORE

answered May 20, 2019 in Power BI by avantika
• 1,500 points
289 views
0 votes
1 answer

How do I show more than one data element in a 'card'?

Hi, In order to show more than one ...READ MORE

answered Jun 13, 2019 in Power BI by avantika
• 1,500 points
96 views
0 votes
1 answer

How do I get my DAX measure to calculate grouped values?

Try this: Total Usage:= SUMX( VALUES(MyTable[SensorID]), [Usage]) An alternative ...READ MORE

answered Oct 8, 2020 in Power BI by Gitika
• 65,850 points
46 views
0 votes
3 answers

How do I get token using javascript API while trying to embed graphs using Power BI

Use ADAL.js that will give you an ...READ MORE

answered Jun 22, 2019 in Power BI by anonymous
2,190 views
0 votes
1 answer
0 votes
1 answer

How to get month name from month number in Power BI?

You can use: MonthName = FORMAT(DATE(1, [Num], 1), ...READ MORE

answered Sep 24, 2020 in Power BI by Alisha
53 views
0 votes
1 answer

How to ignore a slicer for one measure, but apply it on another?

In order to ignore Slicer you need ...READ MORE

answered Oct 1, 2020 in Power BI by Gitika
• 65,850 points
653 views
0 votes
1 answer

How do I use the DAX function ParallelPeriod?

The DAX expression you used in the ...READ MORE

answered Oct 5, 2020 in Power BI by Gitika
• 65,850 points
58 views
0 votes
1 answer

In DAX, how do I RETURN the sum of a calculated column from a DAX Table Variable (created via ADDCOLUMN)?

You can access column variables of previously ...READ MORE

answered Oct 8, 2020 in Power BI by Gitika
• 65,850 points
372 views
0 votes
3 answers

How to create final table based on Joins of two tables in power BI?

To do so, follow these steps: From the ...READ MORE

answered Dec 16, 2020 in Power BI by Gitika
• 65,850 points
12,170 views