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
marmaghan
Frequent Visitor

Calculate LM performing Retailers this NON Performing

Hi All,

 

I need to calculate how many retailers last month whose sales >0 having this month sales =0,

Please help me in this case should I have to create a calculated column or use measure I am stuck on both cases.

 

I have a simple table which have dates, unique retailers per date and their sales amount but unable to identify retailers from above criteria I am using excel 2016 BI

 

6 REPLIES 6
Greg_Deckler
Super User
Super User

See attached PBIX.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg for Reply your solution was very helpful but I have much more complex situation here. First find below my data

 

DateSub-RegionRegion CodeSale IDAgent TypeRetailer IDPERFORMER_TAGRET_SEGMENTDaily AvgEOD BALANCELD USAGE TOTALMTD USAGE TOTAL
8/31/2018South 1S1-GBT-047034Retailer1404392PERFORMERC:Silver210050
8/31/2018South 1S1-GBT-047149Retailer2102301PERFORMERB:Gold69621021,585
8/31/2018South 1S1-GBT-047149Retailer2176999PERFORMERB:Gold1,2937040,080
8/31/2018South 1S1-GBT-047149Retailer2284888PERFORMERC:Silver36,8110100
8/31/2018South 1S1-GBT-047149Retailer2284999PERFORMERC:Silver1113,2211003,450
8/31/2018South 1S1-GBT-047149Retailer2502333PERFORMERC:Silver277870830
8/31/2018South 1S1-GBT-047149Retailer2746273PERFORMERC:Silver6522302,030
8/31/2018South 1S1-GBT-047149Retailer2747497PERFORMERC:Silver231207,167
8/31/2018South 1S1-GBT-047149Retailer2390514PERFORMERC:Silver197030
8/31/2018South 1S1-GBT-047149Retailer2390518PERFORMERC:Silver1530460
8/31/2018South 1S1-GBT-047149Retailer2390623PERFORMERC:Silver5230150
8/31/2018South 1S1-GBT-047149Retailer2390863PERFORMERC:Silver41011012,710
8/31/2018South 1S1-GBT-047149Retailer2392834PERFORMERC:Silver22070
8/31/2018South 1S1-GBT-047149Retailer2393974PERFORMERC:Silver65621502,010
8/31/2018South 1S1-GBT-047149Retailer2394276PERFORMERC:Silver6962202,150
8/31/2018South 1S1-GBT-047149Retailer2395974PERFORMERC:Silver15030
8/31/2018South 1S1-GBT-047149Retailer2396433PERFORMERC:Silver118403,665
8/31/2018South 1S1-GBT-047149Retailer2397433PERFORMERB:Gold3,0712,774095,191
8/31/2018South 1S1-GBT-047149Retailer2397745PERFORMERC:Silver132604,104
8/31/2018South 1S1-GBT-047149Retailer2399006PERFORMERC:Silver1700515
8/31/2018South 1S1-GBT-047149Retailer2399199PERFORMERC:Silver1,26626039,260

 

now as you can see I have MTD sales in my data so I don't need month wise filtering I have replaced current month and previous month as dates and I have heirarchy of retailer id , Sales ID , Region Code.

your solution is working fine when run in Card tile only but when I use this in pivot table which have Date External Filter and Region Code & Ret_Segement on row this is not working fine below snapshot
in below mention Pic Total Retailer is Current Date Retailer which is filtered throught external date and mmm measure is created with this code

 

 

=VAR __currentDate = MAX('EVC Last Day'[Date])
VAR __lastMonthDate = date(2018,8,31)
VAR __tmpTable = SUMMARIZE(ALL('EVC Last Day'),'EVC Last Day'[Retailer ID],"__LastMonth",SUMX(FILTER('EVC Last Day','EVC Last Day'[Date]=__lastMonthDate),'EVC Last Day'[MTD USAGE TOTAL]),"__ThisMonth",SUMX(FILTER('EVC Last Day','EVC Last Day'[Date]=__currentDate),'EVC Last Day'[MTD USAGE TOTAL]))
RETURN COUNTROWS(FILTER(__tmpTable,[__ThisMonth]=0 && [__LastMonth]>0))

how to make this more dynamically please help

 

image.png

 

 

 

 

 

 

=VAR __currentDate = MAX('EVC Last Day'[Date])
VAR __lastMonthDate = date(2018,8,31)
VAR __tmpTable = SUMMARIZE(ALL('EVC Last Day'),'EVC Last Day'[Retailer ID],"__LastMonth",SUMX(FILTER('EVC Last Day','EVC Last Day'[Date]=__lastMonthDate),'EVC Last Day'[MTD USAGE TOTAL]),"__ThisMonth",SUMX(FILTER('EVC Last Day','EVC Last Day'[Date]=__currentDate),'EVC Last Day'[MTD USAGE TOTAL]))
RETURN COUNTROWS(FILTER(__tmpTable,[__ThisMonth]=0 && [__LastMonth]>0))

 

 

 

 

 

 

 

 

 

 

 

 

@marmaghan,

I didn't get same picture as yours when creating measure based on the above sample data. Could you please post expected result based on the above sample data?

Regards,
Lydia

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

I need above measure should be created in such a way that it can count according to rows filters & date filter is that possible.

I have just provide you few lines for understaning of sample data it is not complete 

Greg_Deckler
Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

In general though, I imagine that the solution will involve SUMMARIZE where the aggregation columns do a SUMX on FILTERED data for previous month and current month. Then you do a COUNTROWS on the FILTER of this SUMMARIZEd temp table based upon your identified criteria and you're home free.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.