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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Tejinder
Helper I
Helper I

DAX Help

Thanks for clicking on this

This is my sample data: 

BarcodeIDOrder IDBOX sequenceTotalBoxesReceived(Y/N)received
100620559195914Y2023-07-18 8:16
100620565195944Y2023-07-18 8:16
100620566195924Y2023-07-18 8:16
100620567195934Nnull
100673629196150644Y2023-07-21 9:01
100673630196150624Y2023-07-21 9:01
100673631196150634Y2023-07-21 9:01
100673632196150614Y2023-07-21 9:01
10068619919667Y2023-07-21 2:16
10068620019677Y2023-07-21 2:16
10068620119657Y2023-07-21 2:16
10068620319637Y2023-07-21 2:52
10068620419647Y2023-07-21 2:13
10068620519617Y2023-07-21 2:13
10068620619627Y2023-07-21 2:13
1006829641961600255Nnull
1006829651961600245Nnull
1006829661961600235Nnull
1006829671961600225Nnull
1006829681961600215Nnull


This is from an inventory scan; scans are done daily on barcode levels.
Every order has multiple boxes and unique barcodes for those boxes, sometimes some or all are not scanned (missing). I would like to summarize it into partially missing, missing, or complete,
For example:

1959 is partial
1961506 is complete
19616002 is missing


There are time stamps for every scan and sometimes some of the orders are scanned multiple times and new records are created, it doesn’t replace existing scans or lack of.

The way I tried to do it is by creating a table by summarizing DAX measure, but it doesn't work for me operationally because some orders are scanned multiple times, Let's take order 1959 for example. If it has 3/4 boxes scanned it will show as partial but if another box is scanned at a later date, it will count it as 4 scans and show it as complete.

I would like to have it in a measure so I can filter it by time/date

Here is my DAX:

Output =

VAR _1 =

SUMMARIZE(

'Table','Table'[Order ID],

"TotBox",Max( 'Table'[TotalBoxes] ),

"Count",

COUNTROWS(

FILTER(

'Table', 'Table'[Received(Y/N)] = "Y"

) )

)

VAR _2 =

ADDCOLUMNS(

_1,"Status",

IF(

[Count]= BLANK(),"Missing",

IF(

[Count] = [TotBox],"Completed",

"Partially Completed"

) ) )

VAR _Result =

SELECTCOLUMNS(

_2,"OrderID",[Order ID],

"Status",[Status]

)

RETURN

_Result

Here is the result 

 

Tejinder_0-1690245806013.png

 

Any help is appreciated.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Tejinder , Create a new column

 

Status =
var _count =
CALCULATE(
COUNTROWS('Table'),
'Table'[Order ID] = earlier('Table'[Order ID]),
'Table'[Received(Y/N)] = "Y"
)
return
IF(
_count = 0, "Missing",
IF(
_count = MAX('Table'[TotalBoxes]), "Completed",
"Partially Completed"
)
)

 

 

New measure

 

StatusMeasure =
VAR _date = MAX('Table'[received])
RETURN
CALCULATE(
VALUES('Table'[Status]),
FILTER('Table', 'Table'[received] <= _date)
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Tejinder , Create a new column

 

Status =
var _count =
CALCULATE(
COUNTROWS('Table'),
'Table'[Order ID] = earlier('Table'[Order ID]),
'Table'[Received(Y/N)] = "Y"
)
return
IF(
_count = 0, "Missing",
IF(
_count = MAX('Table'[TotalBoxes]), "Completed",
"Partially Completed"
)
)

 

 

New measure

 

StatusMeasure =
VAR _date = MAX('Table'[received])
RETURN
CALCULATE(
VALUES('Table'[Status]),
FILTER('Table', 'Table'[received] <= _date)
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for your help
It does not work, here are the screenshots, 

Tejinder_0-1690254225099.png
The idea is that,  i can use a date/time range from a filter. to select a particular window

 

Tejinder
Helper I
Helper I

..

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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