Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Hongmingk
Frequent Visitor

Cumulative Reject Count

Hi all,

 

I have a table with all the rejects information for individual items. I want to do a cumulative of all the rejects description for individual items. 

Hongmingk_0-1701152380668.png

 

As you can see above, the _cumReject works normal until Oil Stains reject, when the reject count reach 1, it stop cumulate and showthe total number of reject instead. By right it should continue to cumulate the rejects (Which is 10 at Clamping Marks). May i sincerly request assist on these. My formula are as below. Thanks

Reject Count = COUNTROWS(FILTER('Reject Data_Raw','Reject Data_Raw'[Reject Desciption] <> BLANK()))
 
_cumReject =
IF (
    ISINSCOPE('Reject Data_Raw'[Reject Desciption]),
    VAR _allselectedComp = ALLSELECTED('Reject Data_Raw'[Reject Desciption])
    VAR _CompTable = ADDCOLUMNS(_allselectedComp, "@Count", 'Reject Data_Raw'[Reject Count])
    VAR _CurrentCount = 'Reject Data_Raw'[Reject Count]
    VAR _CumCompTable = FILTER(_CompTable, [@Count] >= _CurrentCount)
    VAR _CumComp = SUMX(_CumCompTable, [@Count])
   
           
    RETURN
        _CumComp
)



1 ACCEPTED SOLUTION

Hi,

Please check the below picture and the attached pbix file if it suits your requirement.

 

Jihwan_Kim_0-1701229998451.png

 

_cumReject =
IF (
    ISINSCOPE ( 'Reject Data'[Reject Desciption] ),
    VAR _allselectedComp =
        ALLSELECTED ( 'Reject Data'[Reject Desciption] )
    VAR _CompTable =
        ADDCOLUMNS ( _allselectedComp, "@Count", 'Reject Data'[Reject Count] )
    RETURN
        SUMX (
            WINDOW (
                1,
                ABS,
                0,
                REL,
                _CompTable,
                ORDERBY ( [@Count], DESC, 'Reject Data'[Reject Desciption], ASC )
            ),
            [@Count]
        )
)

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

6 REPLIES 6
Jihwan_Kim
Super User
Super User

Hi, I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I hope the below can provide some ideas on how to create a solution for your semantic model.

 

Jihwan_Kim_1-1701154096902.png

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

Jihwan_Kim_0-1701154082254.png

 

Cumulative reject count: =
VAR _t =
    ADDCOLUMNS (
        SUMMARIZE ( ALL ( reject_fct ), item_dim[Category], item_dim[Item] ),
        "@rejectcount", CALCULATE ( COUNTROWS ( reject_fct ), reject_fct[Reject Description] = 1 )
    )
RETURN
    SUMX (
        WINDOW (
            1,
            ABS,
            0,
            REL,
            _t,
            ORDERBY ( [@rejectcount], DESC, item_dim[Item], ASC ),
            ,
            PARTITIONBY ( item_dim[Category] )
        ),
        [@rejectcount]
    )

 

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Hi, Thanks for the replies. Actually i only have one table. There's no other table to link the relation. 

 

I tried to create a new table similar to Item_Dim. Unfortunally i cant use the way you provided. As my reject description has duplicate value due to some of the item have similar reject descriptions as reflected in the table below.

 

Hongmingk_0-1701163000334.png

Hence, may i ask is there any other ways to achieve the results?

 

Thanks.

Hi,

Please provide your sample pbix file's link (onedrive, google drive, dropbox, or others), and then I can try to look into the sample.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Hi,

 

Kindly find the pbix file's link and the excel file sample link below. 

 

Reject Visual.pbix

Rejects_Data.xlsx

 

Much apperiacted for your help. Thanks

Hi,

Please check the below picture and the attached pbix file if it suits your requirement.

 

Jihwan_Kim_0-1701229998451.png

 

_cumReject =
IF (
    ISINSCOPE ( 'Reject Data'[Reject Desciption] ),
    VAR _allselectedComp =
        ALLSELECTED ( 'Reject Data'[Reject Desciption] )
    VAR _CompTable =
        ADDCOLUMNS ( _allselectedComp, "@Count", 'Reject Data'[Reject Count] )
    RETURN
        SUMX (
            WINDOW (
                1,
                ABS,
                0,
                REL,
                _CompTable,
                ORDERBY ( [@Count], DESC, 'Reject Data'[Reject Desciption], ASC )
            ),
            [@Count]
        )
)

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Hi,

 

It work perfectly! Thanks alot for your assist and guidance.

 

Thanks.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.