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
gunasai
Helper I
Helper I

Find the number/percentage of orders with 1 item ordered

Hi,

Consider I have the following table,

 

Order NumberItem CodeCustomerQty_orderedPrice
11111ABC10100
11112ABC20200
22221XYZ550
33332EFG550
44442FFF10100

 

I want to find the Number of orders/Percentage of orders that has ordered only 1 item.

In the above case, it should display only the rows 3,4,5 as "3 orders" or "75% of orders" have only 1 item ordered.

 

Can you please help me with the DAX or any other method?

 

Thanks in advance.

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @gunasai ,

 

If you want to display the nmuber of orders with 1 item orderd, follow me step by step.

1 create a table visual and drag field Order Number into the table

2 drag the item code into the table visual but set the fields to count like the following show via the downward-pointing arrow:

vchenwuzmsft_0-1632446009993.png

3 Then set the filters on the visual, count of Item Code is 1, and click Apply filter, as the image show. you can remove the field count of item code in table if you do not want to display the count of the order number, it wont affect the existing result.

vchenwuzmsft_1-1632446009995.png

 

 

 

If you want to display the percentage of 1 order

Try this measure:

 

Measure =
VAR _allNmuber =
    DISTINCTCOUNT ( 'Table'[Order Number] )
VAR _1order =
    COUNTROWS (
        FILTER (
            SUMMARIZE (
                'Table',
                'Table'[Order Number],
                "if1", DISTINCTCOUNT ( 'Table'[Item Code] )
            ),
            [if1] = 1
        )
    )
RETURN
    DIVIDE ( _1order, _allNmuber )

 

 

Here is my pbix file you can reference.

 

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @gunasai ,

 

If you want to display the nmuber of orders with 1 item orderd, follow me step by step.

1 create a table visual and drag field Order Number into the table

2 drag the item code into the table visual but set the fields to count like the following show via the downward-pointing arrow:

vchenwuzmsft_0-1632446009993.png

3 Then set the filters on the visual, count of Item Code is 1, and click Apply filter, as the image show. you can remove the field count of item code in table if you do not want to display the count of the order number, it wont affect the existing result.

vchenwuzmsft_1-1632446009995.png

 

 

 

If you want to display the percentage of 1 order

Try this measure:

 

Measure =
VAR _allNmuber =
    DISTINCTCOUNT ( 'Table'[Order Number] )
VAR _1order =
    COUNTROWS (
        FILTER (
            SUMMARIZE (
                'Table',
                'Table'[Order Number],
                "if1", DISTINCTCOUNT ( 'Table'[Item Code] )
            ),
            [if1] = 1
        )
    )
RETURN
    DIVIDE ( _1order, _allNmuber )

 

 

Here is my pbix file you can reference.

 

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@gunasai , Try a measure like

 

divide(countx(filter(summarize(Table, Table[Order Number],"_1", distinctCOUNT(Table[Item Code])), [_1]=1),[Order Number]),distinctCOUNT(Table[Order Number]))

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.