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

DAX vs power query for Summariing data ?

Thanks for clicking on this
This is my sample data:

BarcodeID Order IDBOX sequenceTotalBoxesReceived(Y/N)received
100620559 195914Y2023-07-18 8:16
100620565 195944Y2023-07-18 8:16
100620566 195924Y2023-07-18 8:16
100620567 195934Nnull
100673629 196150644Y2023-07-21 9:01
100673630 196150624Y2023-07-21 9:01
100673631 196150634Y2023-07-21 9:01
100673632 196150614Y2023-07-21 9:01
100686199 19667Y2023-07-21 2:16
100686200 19677Y2023-07-21 2:16
100686201 19657Y2023-07-21 2:16
100686203 19637Y2023-07-21 2:52
100686204 19647Y2023-07-21 2:13
100686205 19617Y2023-07-21 2:13
100686206 19627Y2023-07-21 2:13
100682964 1961600255Nnull
100682965 1961600245Nnull
100682966 1961600235Nnull
100682967 1961600225Nnull
100682968 1961600215Nnull


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:  

Order ID

Status

1959

Partial missing

1961506

Complete

196

Complete

19616002

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 scan or lack of.

Way I tried to achieve this is by counting time stamps in power query and group by Order ID and compare to TotalBoxes Col, but that didn’t work as it was adding all instances from multiple days, for example: Order ID 1959 would show 6 scans but only have 4 boxes. Because some boxes were scanned at a later date.

How can I do this easily in DAX?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Tejinder ,

 

Try this measure:

Status = var _countid=CALCULATE(COUNT('Table'[Order ID]),FILTER(ALLSELECTED('Table'),[Order ID]=MAX('Table'[Order ID])))
var _countreceived=CALCULATE(COUNT('Table'[received]),FILTER(ALLSELECTED('Table'),[Order ID]=MAX('Table'[Order ID])&&[received]<>BLANK()))+0
return SWITCH(TRUE(),_countreceived=0,"Missing",_countid=_countreceived,"Complete",_countid<>_countreceived,"Partial missing")

vstephenmsft_0-1690338133316.png

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

4 REPLIES 4
Anonymous
Not applicable

Hi @Tejinder ,

 

Try this measure:

Status = var _countid=CALCULATE(COUNT('Table'[Order ID]),FILTER(ALLSELECTED('Table'),[Order ID]=MAX('Table'[Order ID])))
var _countreceived=CALCULATE(COUNT('Table'[received]),FILTER(ALLSELECTED('Table'),[Order ID]=MAX('Table'[Order ID])&&[received]<>BLANK()))+0
return SWITCH(TRUE(),_countreceived=0,"Missing",_countid=_countreceived,"Complete",_countid<>_countreceived,"Partial missing")

vstephenmsft_0-1690338133316.png

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

sanalytics
Super User
Super User

Hello @Tejinder 
Based on your shared data and explanation , i have used ReceivedY/N column for achiving your desired result.

Please find the below DAX code

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 it is the screenshot
sanalytics_0-1690194887049.png

 

Hope this will help you.

 

Regards

sanalytics

If it is your solution then please like and accept it as solution

 

This works but doesn't work for me operationally. 
I can't have it in a separate table. it complicates it as some orders are scanned on different days, 

Let's assume Order 1959 was missing one piece but it was scanned at a later date, this would show it as completed. 

Instead of adding a column, can it be a measure so i can filter by time/date and then have it reflect if the order is complete partial or missing?


Idrissshatila
Super User
Super User

Hello @Tejinder ,

 

check the summarizing dax function and tru applying it https://learn.microsoft.com/en-us/dax/summarizecolumns-function-dax

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




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.