cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
shankarshiva70
Helper III
Helper III

Cumulative unique count based on sales values-DAX

Hi expert,

 

I am stucking on to calculate cumulative unique count in DAX month on month basis some criteria,

please help me to get this done.

Thanks a ton in advance.

@Icey @Tanushree_Kapse @VahidDM @Cregg @amitchandak @pbig @administrator @PBICommunity @PBCommunity 

Raw data and summary below.

shankarshiva70_0-1636956704783.png

Please help me on this.

Thanks

 

1 ACCEPTED SOLUTION

Thanks VahidDM.

Basis on your logic , I have added on other criteria basis my data and  have applied in my project is working . Got what I was looking for.

 

Dist_Count_Retailer_for_repeat_Analysis  = calculate(DISTINCTCOUNT('db_CSA_Data Yield_Sec_Test'[Distributor+finalvittrackcode]),FILTER(SUMMARIZE('db_CSA_Data Yield_Sec_Test','db_CSA_Data Yield_Sec_Test'[Distributor+finalvittrackcode],Dates[CalYear],Dates[MOC_Name_Auto_New],'db_CSA_Data Yield_Sec_Test'[Pri_Sec],'db_CSA_Data Yield_Sec_Test'[DistributorCode],SAP_CSA_Tbl_Customer_Master[DB Name],SAP_CSA_Tbl_Customer_Master[State_Mapping.Region-Group],SAP_CSA_Tbl_Customer_Master[State_Mapping.State Group],SAP_CSA_Tbl_Customer_Master[City name],'Channel_Index Final'[Final Channel],Dates[MOC_Code_Auto_New for repeat],"Sum of Qty",SUM('db_CSA_Data Yield_Sec_Test'[Quantity]),"Sum of Yield",SUM('db_CSA_Data Yield_Sec_Test'[Actualyield])),[Sum of Qty]<>0&&'db_CSA_Data Yield_Sec_Test'[Pri_Sec]="Sec inc P=S"))
 
Thanks.

View solution in original post

4 REPLIES 4
VahidDM
Super User
Super User

Hi @shankarshiva70 

 

Try this measure:

 

 

Measure1 = 
VAR _A =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Cust] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Months] < MAX ( 'Table'[Months] )
                && 'Table'[sales flag] = 1
        )
    )
RETURN
    IF ( ISBLANK ( _A ), 0, _A )

 

 

output:

VahidDM_1-1636957374309.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

Thank u so much for quick reply and looking correct . but while applying in my live data , not getting correct output

Sorry My data is at invoice level hence one customer can have mulitple records basis on their billing in same month but have to check the sales at customer level while counting in month.

like base raw data will be.

output will be same

shankarshiva70_0-1636962861793.png

 

Thanks VahidDM.

Basis on your logic , I have added on other criteria basis my data and  have applied in my project is working . Got what I was looking for.

 

Dist_Count_Retailer_for_repeat_Analysis  = calculate(DISTINCTCOUNT('db_CSA_Data Yield_Sec_Test'[Distributor+finalvittrackcode]),FILTER(SUMMARIZE('db_CSA_Data Yield_Sec_Test','db_CSA_Data Yield_Sec_Test'[Distributor+finalvittrackcode],Dates[CalYear],Dates[MOC_Name_Auto_New],'db_CSA_Data Yield_Sec_Test'[Pri_Sec],'db_CSA_Data Yield_Sec_Test'[DistributorCode],SAP_CSA_Tbl_Customer_Master[DB Name],SAP_CSA_Tbl_Customer_Master[State_Mapping.Region-Group],SAP_CSA_Tbl_Customer_Master[State_Mapping.State Group],SAP_CSA_Tbl_Customer_Master[City name],'Channel_Index Final'[Final Channel],Dates[MOC_Code_Auto_New for repeat],"Sum of Qty",SUM('db_CSA_Data Yield_Sec_Test'[Quantity]),"Sum of Yield",SUM('db_CSA_Data Yield_Sec_Test'[Actualyield])),[Sum of Qty]<>0&&'db_CSA_Data Yield_Sec_Test'[Pri_Sec]="Sec inc P=S"))
 
Thanks.

Thanks VahidDM.

Basis on your logic , I have added on other criteria basis my data and  have applied in my project is working . Got what I was looking for.

 

Dist_Count_Retailer_for_repeat_Analysis  = calculate(DISTINCTCOUNT('db_CSA_Data Yield_Sec_Test'[Distributor+finalvittrackcode]),FILTER(SUMMARIZE('db_CSA_Data Yield_Sec_Test','db_CSA_Data Yield_Sec_Test'[Distributor+finalvittrackcode],Dates[CalYear],Dates[MOC_Name_Auto_New],'db_CSA_Data Yield_Sec_Test'[Pri_Sec],'db_CSA_Data Yield_Sec_Test'[DistributorCode],SAP_CSA_Tbl_Customer_Master[DB Name],SAP_CSA_Tbl_Customer_Master[State_Mapping.Region-Group],SAP_CSA_Tbl_Customer_Master[State_Mapping.State Group],SAP_CSA_Tbl_Customer_Master[City name],'Channel_Index Final'[Final Channel],Dates[MOC_Code_Auto_New for repeat],"Sum of Qty",SUM('db_CSA_Data Yield_Sec_Test'[Quantity]),"Sum of Yield",SUM('db_CSA_Data Yield_Sec_Test'[Actualyield])),[Sum of Qty]<>0&&'db_CSA_Data Yield_Sec_Test'[Pri_Sec]="Sec inc P=S"))
 
Thanks.

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors