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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
nmlinden
Regular Visitor

Need help with CALCULATE formula referencing different data sources

I am converting an Excel report to Power BI and need help with the DAX formula as I am creating a new column in one of my tables. 

The Excel formula looks like this:

=COUNTIF(SHEET_1[UsersEmail],[@UsersEmail])+COUNTIF(SHEET_2[UsersEmail],[@UsersEmail])+COUNTIF(SHEET_3[UsersEmail],[@UsersEmail])+COUNTIF(SHEET_4[UsersEmail],[@UsersEmail])

 

The purpose of the formula is to count the instances that the user's email shows up on each of the sheets that are referenced in the formula. I need the same count in PBI. 

I know I need to use the CALCULATE DAX formula but am having trouble understanding how to reference  each table and complete the formula in its entirety. 

Hopefully my explaination makes sense.

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @nmlinden ,

 

I create an sample with four tables.

vcgaomsft_1-1646632676711.png

Then use Transform data.

vcgaomsft_2-1646632811049.png

Use Append queries.

vcgaomsft_3-1646632954400.png

vcgaomsft_0-1646632367018.png

Close & Apply.

vcgaomsft_4-1646633100990.png

Then use the following expression to create the calculated column.

vcgaomsft_5-1646633233454.png

 

The number of occurrences = CALCULATE(COUNT(Sheet_1[UsersEmail]))

 

Please check if the result matches your expectations.

vcgaomsft_6-1646633584788.png

Attach the PBIX file for reference. Hope it helps.

 

If this doesn't work for you, please consider sharing more details about it. And it would be great if there was a sample file without any sensitive information here.

 

It makes it easier to give you a solution.

  1. Sample (dummy dataset) data as text, use the table tool in the editing bar.
  2. Expected output from sample data.
  3. Explanation in words of how to get from 1. to 2.

 

Best Regards,
Community Support Team_Gao

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

4 REPLIES 4
v-cgao-msft
Community Support
Community Support

Hi @nmlinden ,

 

I create an sample with four tables.

vcgaomsft_1-1646632676711.png

Then use Transform data.

vcgaomsft_2-1646632811049.png

Use Append queries.

vcgaomsft_3-1646632954400.png

vcgaomsft_0-1646632367018.png

Close & Apply.

vcgaomsft_4-1646633100990.png

Then use the following expression to create the calculated column.

vcgaomsft_5-1646633233454.png

 

The number of occurrences = CALCULATE(COUNT(Sheet_1[UsersEmail]))

 

Please check if the result matches your expectations.

vcgaomsft_6-1646633584788.png

Attach the PBIX file for reference. Hope it helps.

 

If this doesn't work for you, please consider sharing more details about it. And it would be great if there was a sample file without any sensitive information here.

 

It makes it easier to give you a solution.

  1. Sample (dummy dataset) data as text, use the table tool in the editing bar.
  2. Expected output from sample data.
  3. Explanation in words of how to get from 1. to 2.

 

Best Regards,
Community Support Team_Gao

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

this is very helpful ,thank you!

nmlinden
Regular Visitor

I have decided that I am going to try to do more in SQL which would help simplify the data, thanks for your response!

littlemojopuppy
Community Champion
Community Champion

Hi @nmlinden 

 

Working with Power BI is very different than working with Excel.  With Excel, everything is based on row/column references.  In Power BI everything is tables and fields, and data modeling is very important.  It would be difficult to provide a good answer without being able to see your data model.  Can you provide your pbix?  Or some mocked up sample data?

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.