cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ratri Frequent Visitor
Frequent Visitor

How to calculate Sum/Totals with an if-condition based on measure?

Hi, 

hope you can help me out. I have following data: 
Customer Table 

CRM Table 

Turnover Table 

the CRM and Turnover are linked through Customer ID to the Customer Table 

Now I need to calculate the Turnover for customer were not visited this year. 

I already calcualted the

1. number of customers

DISTINCTCOUNT(Personenkonto_1[CustomerID])
2. number of visits in a year for the customer 
CALCULATE([Anzahl Vorgänge];FILTER('Aktivität CRM_9';'Aktivität CRM_9'[Bezeichnung]="Visit");all(Team_6[Team]))

3. Sales for the customer in a year 

CALCULATE(sum(Mengendaten[Sales]);USERELATIONSHIP(Bereichsbezeichnung[Bereich];Mengendaten[Bereichsbezeichnung]))
 

So how can i build up a formula ? I tried with an if-function: if(number of visits<=0;Sales;0) --> it turns the correct value, but the Total Sum field in the table is showing 0, But i need the total Sales value for those customers that were not visited yet. 


any idea? 


Regards, 

Anastasija

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to calculate Sum/Totals with an if-condition based on measure?

Hi @ratri 

 

Please add a new measure instead:

Measure = SUMX(Customer,[Calculate Sales for no visits])

0006.PNG 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

5 REPLIES 5
Super User IV
Super User IV

Re: How to calculate Sum/Totals with an if-condition based on measure?

Please refer hasonevalue

 

https://docs.microsoft.com/en-us/dax/hasonevalue-function-dax





Did I answer your question? Mark my post as a solution!
In case it does not help, please provide additional information and mark me with @
My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP,
HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Super User! Linkedin


ratri Frequent Visitor
Frequent Visitor

Re: How to calculate Sum/Totals with an if-condition based on measure?

Hi, 

 

hasonavlue referst to column. But i have no column that is indicating the number of visits. i have only a measure and with measure HASONVALUE is not working. 

 

BG,

Ratri

Community Support Team
Community Support Team

Re: How to calculate Sum/Totals with an if-condition based on measure?

Hi @ratri 

 

You might consider creating pbix file that will contain some sample data, upload the pbix to onedrive or dropbox and share the link to the file. Please do not forget to describe the expected results based on this sample data.

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
ratri Frequent Visitor
Frequent Visitor

Re: How to calculate Sum/Totals with an if-condition based on measure?

Hi, 

 

i created an example. Hope you can download it in DropBox: 

 

https://www.dropbox.com/s/2oooowkph8q5rld/Example%20issue.pbix?dl=0 

 

Ratri

Community Support Team
Community Support Team

Re: How to calculate Sum/Totals with an if-condition based on measure?

Hi @ratri 

 

Please add a new measure instead:

Measure = SUMX(Customer,[Calculate Sales for no visits])

0006.PNG 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors