Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

SUM COUNTIFS from 2 tables from Excel to Dax

Hi, 

In Excel i have made the below table.

I currently have two excel sheets which i have pasted together. 

 

Sheet 1 has the Date and ID Column in. (First 2 Columns)

Sheet 2 has ID2 Column in.

 

QQ_bi_0-1643037415950.png

 

I have created the formula below.

=SUM(COUNTIF(C1:C20,B1))

=SUM(COUNTIF((ID2 All Rows,ID Row 1)

I have highlighted the cells to show the matches.

 

So basically i want to look at each row in Column ID and check how many times it occurs in Column ID2 and produce the value in the Desired Output Column. 

 

How would i produce this as DAX in powerbi.

Any help is much appreciated! 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Here is one way to create a new column to get the result. 

Column = COUNTROWS(FILTER('Table','Table'[ID2]=EARLIER('Table'[ID])))+0

22012702.jpg

 

If you load data from two sheets into two tables in Power BI, you can bring data from table2 to table1 by merging queries before adding the new column. See How To Merge Queries In Power BI | Enterprise DNA

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Here is one way to create a new column to get the result. 

Column = COUNTROWS(FILTER('Table','Table'[ID2]=EARLIER('Table'[ID])))+0

22012702.jpg

 

If you load data from two sheets into two tables in Power BI, you can bring data from table2 to table1 by merging queries before adding the new column. See How To Merge Queries In Power BI | Enterprise DNA

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

AUaero
Responsive Resident
Responsive Resident

Try this:

# Desired Output = 
VAR CurrentID = MAX(IDs[ID])

RETURN
CALCULATE(
    COUNTROWS(IDs),
    FILTER(
        ALL(IDs),
        IDs[ID2] = CurrentID
    )
)

 

AUaero_0-1643038727950.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.