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
Roseventura
Responsive Resident
Responsive Resident

Get the Total or Sum of a Measure

I've seen numerous instances of this problem solved, but for some reason, I can't get any to work for me.  All I want to do is create a measure that calculates the TOTAL number of Lost Customers (in this case, 4).  Can someone tell me what I'm doing wrong?  

 

The table visual shows the Customer Code and Total Sales for each Customer.  The Sales During Churn Period measure looks at a What-if Parameter value that the user can change.  In this example, the Churn Time Period = 12 (months).

Any customer with no sales during that 12 month period is considered "Lost".  See measures below.

 

Capture 52.JPG

 

MEASURES:

 

Total Sales = calculate(sum(Shipments[Ext Unit Price]))
 
Sales During Churn Period =
var DIP = DATESINPERIOD(Shipments[Transaction Date], lastdate(Shipments[Transaction Date]),
'Churn Time Period (Months)'[Churn Time Period Value], MONTH)
return
calculate([Total Sales] , DIP )
 
Lost Customers = if ( [Sales During Churn Period], 0, 1 )
 
One of the many measures I've tried is this:
 
Count Lost Customers =
countrows(filter(values(Shipments[CUST_CODE]),[Lost Customers] = 1 ))
 
but as you can see from the reference above, this measure returns Blank, nada, zilch.
 
What am I missing?
 
 
 
 
 
 
 
 
 

 

1 ACCEPTED SOLUTION
Roseventura
Responsive Resident
Responsive Resident

I figured out the correct measure:

 

Count Lost Customers =
VAR LostCust =
ADDCOLUMNS ( VALUES ( CustMaster[CUST_CODE] ), "Lost Customers", [Lost Customers] )
VAR vResult =
sumx(LostCust, if([Lost Customers] = 1, 1, 0) )
RETURN
vResult
 
 
What made the difference is that I had to use the Customer Master Lookup table in the
ADDCOLUMNS measure because (of course) if I just looked at the shipments table,
that wouldn't show any customers that were lost (DUH!) But since Customer Master has ALL
customers, it will allow me to add those with NO sales.

View solution in original post

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

Have you been able to solve your problem? I have the same

Did you solve your problem? I have the same one

Roseventura
Responsive Resident
Responsive Resident

I figured out the correct measure:

 

Count Lost Customers =
VAR LostCust =
ADDCOLUMNS ( VALUES ( CustMaster[CUST_CODE] ), "Lost Customers", [Lost Customers] )
VAR vResult =
sumx(LostCust, if([Lost Customers] = 1, 1, 0) )
RETURN
vResult
 
 
What made the difference is that I had to use the Customer Master Lookup table in the
ADDCOLUMNS measure because (of course) if I just looked at the shipments table,
that wouldn't show any customers that were lost (DUH!) But since Customer Master has ALL
customers, it will allow me to add those with NO sales.
Jihwan_Kim
Super User
Super User

Hi, @Roseventura 

Please correct me if I wrongly understood your question.

Please try the below measure.

 

newmeasure =
SUMX ( VALUES ( PBI_AEP_Shipments_Multi_byLn[CUST_CODE] ), [Lost Customers] )

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Jihwan,

 

That did not work.  It returned 0.  If you notice in the table visual, the total at the bottom of the Count Lost Customers measure is 0 because it's evaluating the total.

 

Rose

 

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.