cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mg_2000
Helper I
Helper I

COUNT IF using a measure

Hi!

 

I have been searching for a way to solve this problem, but can't get it to work - so trying here instead. 

I have a DAX IF-formula like below for calculating new customers: 

IF([Sales Previous 4weeks TY] >0, IF([Sales Previous 4weeks TY] = [Sales Previous X-Months TY], 1, 0)
The problem is that it will not count the number of customers..  How can I solve this the easiest? Any count formula and/ or other idea?
 
Thanks in advance!
 
 
1 ACCEPTED SOLUTION
MFelix
Super User III
Super User III

Hi @mg_2000,

 

Based on the calculation you present you need to have a SUMX to calculate this values something similar to:

 

Measure = SUMX(Values(Table[Customer), IF([Sales Previous 4weeks TY] >0, IF([Sales Previous 4weeks TY] = [Sales Previous X-Months TY], 1, 0) )

 

However looking at your formula this probably will not work correctly because of context. What you need to do is to calculate all a summarize table with the values of the customers and both measures.

 

In order to give you the correct resutls, can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
mg_2000
Helper I
Helper I

Hi and thanks for a quick reply, 

@MFelix  I have now created a sample file as show exactly the same issue as I getting with my real data. 

As you see here is the bottom row showing "0", the number I am after here is 3.

mg_2000_0-1613592771178.png

 

MFelix
Super User III
Super User III

Hi @mg_2000,

 

Based on the calculation you present you need to have a SUMX to calculate this values something similar to:

 

Measure = SUMX(Values(Table[Customer), IF([Sales Previous 4weeks TY] >0, IF([Sales Previous 4weeks TY] = [Sales Previous X-Months TY], 1, 0) )

 

However looking at your formula this probably will not work correctly because of context. What you need to do is to calculate all a summarize table with the values of the customers and both measures.

 

In order to give you the correct resutls, can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Top Kudoed Authors