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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Tavi_
Frequent Visitor

On Time total order level correct

2025-04-16 16_28_45-Power BI.png

 

See the picture above. How do I get the correct of amount of total orders on time (22% | 2 orders on time, total of 9 orders)?

 

Dump in Excel.

OrderOrder LineSales Order CountSales Order Count LinesSales Order Count Lines On TimeSales Order Lines On TimeSales Order On Time
00001149730000114973_00004011  0%
00001149730000114973_00005011  0%
00001158250000115825_00004011  0%
00001193600000119360_00006011  0%
00001205780000120578_00008011  0%
00001213040000121304_000080111100%100%
00001216740000121674_00005011  0%
00001216740000121674_00006011  0%
00001230460000123046_000020111100%100%
00001230460000123046_000030111100%100%
00001230460000123046_00007011  0%
00001230470000123047_000010111100%100%
00001230470000123047_00002011  0%
00001239080000123908_000050111100%100%

 

Currently I'm using this DAX formula

Sales Order On Time = IF([Sales Order Count] = 1, IF([Sales Order Count Lines] = [Sales Order Count Lines In Time], 1, 0), BLANK())



1 ACCEPTED SOLUTION

Sales Order On Time =
VAR a =
    ADDCOLUMNS (
        VALUES ( 'Table'[Order] ), -- get distinct order numbers
        "r"CALCULATE ( COUNTROWS ( 'Table' ) ), -- get number of line items per order
        "o",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                'Table'[Sales Order Count Lines On Time] = 1 -- get number of line items per order that are on time
            )
    )
RETURN
    COUNTROWS ( FILTER ( a, [r] = [o] && [o] > 0 ) ) -- count the number of orders where all line items are on time (the number of "on time" line items is not zero, and matches the number of total order line items

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

you are using a calculated column without aggregation.  You probably want to use a measure instead.

 

Sales Order On Time = 
var a = ADDCOLUMNS(VALUES('Table'[Order]),"r",calculate(COUNTROWS('Table')),"o",CALCULATE(COUNTROWS('Table'),'Table'[Sales Order Count Lines On Time]=1))
return countrows(filter(a,[r]=[o] && [o]>0))

lbendlin_1-1744835437463.png

 

 

 

Thanks, it is not working in mine dataset yet. Could you explain your steps?

Sales Order On Time =
VAR a =
    ADDCOLUMNS (
        VALUES ( 'Table'[Order] ), -- get distinct order numbers
        "r"CALCULATE ( COUNTROWS ( 'Table' ) ), -- get number of line items per order
        "o",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                'Table'[Sales Order Count Lines On Time] = 1 -- get number of line items per order that are on time
            )
    )
RETURN
    COUNTROWS ( FILTER ( a, [r] = [o] && [o] > 0 ) ) -- count the number of orders where all line items are on time (the number of "on time" line items is not zero, and matches the number of total order line items

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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