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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Pradeepthi23
Frequent Visitor

Conditional Count

Hi I want to calculate the count of orders where the report in code ends with 0,1,2,3,4,5,6,7,8,9 saperately and display the count of orders with respect to the ending values of report in code.

Pradeepthi23_0-1656656782196.png

Pradeepthi23_1-1656656822687.png

 

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@Pradeepthi23 
I used a different sample but remains the same code. First create a filter table containg the digits 0 to 9

1.png

Create your measure as below and slice by the code ending column from the newly created table.

3.png

View solution in original post

7 REPLIES 7
tamerj1
Super User
Super User

@Pradeepthi23 
This with fixed total if it may have any meaninng.
2.png

Code Ending Count = 
SUMX ( 
    VALUES ( 'Code Ending'[Code Ending] ),
    CALCULATE (
        SUMX (
            VALUES ( Orders[Report in Code - Display] ),
            VAR CurrentEnding = SELECTEDVALUE ( 'Code Ending'[Code Ending] )
            VAR CurrentCode = Orders[Report in Code - Display]
            VAR EndOfCode = VALUE ( RIGHT ( CurrentCode, 1 ) )
            RETURN 
                IF ( EndOfCode = CurrentEnding, 1 )
        )
    )
)

Hi @tamerj1 , Thankyou for the solution, what would be the solution if the ending codes have other values like "A-Z" other than numbers.

Anonymous
Not applicable

Hi @Pradeepthi23,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

@Pradeepthi23 

Would be almost the same

Code Ending Count = 
SUMX ( 
    VALUES ( 'Code Ending'[Code Ending] ),
    CALCULATE (
        SUMX (
            VALUES ( Orders[Report in Code - Display] ),
            VAR CurrentEnding = SELECTEDVALUE ( 'Code Ending'[Code Ending] )
            VAR CurrentCode = Orders[Report in Code - Display]
            VAR EndOfCode =  RIGHT ( CurrentCode, 1 )
            RETURN 
                IF ( EndOfCode = CurrentEnding, 1 )
        )
    )
)
tamerj1
Super User
Super User

@Pradeepthi23 
I used a different sample but remains the same code. First create a filter table containg the digits 0 to 9

1.png

Create your measure as below and slice by the code ending column from the newly created table.

3.png

tamerj1
Super User
Super User

Hi @Pradeepthi23 
Please provide a copy/pase sample of data. Thank you

52R8Z4024223260010
52R8Z4024384790010
52R9Z4023432040010
52R9Z4023992290010
52R9Z4024116030010
52W0Z4010402440010
52W0Z4020015100010
52W0Z4020022470010
52W0Z4021628530010
52W1Z4013535710010

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.