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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
modi123p
Helper III
Helper III

Stack or List operation in DAX

Hi,

I have a log table that captures system statuses by time.

I need to create a Snapshot view(Table) that contains  a column with date, order no and concatenated active statuses by removing the ones that are In Active(or closed). The requirement is to perfrom Stack like operation and remove the latest corresponding entry/ perform List like Operation and remove the earliest corresponding entry.

 

System Statuses can repeat and multiple entries can be active at a specific time

 

For example, for Order No 10001 Status Code on 

 

2021-01-02  : CRTD, INPL, PLND, WFMR

2021-01-03  : CRTD, INPL, PLND, WFMR

2021-01-04  : CRTD, INPL, PLND, WFMR

2021-01-05  : CRTD, INPL, PLND, ORTS, INPL  ----> WFMR  is removed as we encountered X for the same on 4th. INPL repeats

2021-01-06  : CRTD, INPL, PLND, ORTS, INPL, PLND, WFMR  ----> WFMR  is re-introduced on 5th

2021-01-07  : CRTD, INPL, PLND, ORTS, INPL, PLND, TECO, CLSD

 

I did a  cross join with Calendar Date (field) and managed to create a Snapshot with all statuses. However removing correpsonding X ones is posing a challenge.

Note: It is not about excluding all statuses with X entry before date. 

For example, if we have a status WFMR showing up thrice with one entry having X ... we need to show WFMR once in the final output.

 

Any help would be appreciated.

 

Order NoDate TimeSystem Status CodeInActive
10002021-01-02 10:45CRTD 
10002021-01-02 11:15INPL 
10002021-01-03 10:45PLND 
10002021-01-03 10:45WFMR 
10002021-01-05 12:45PLNDX
10002021-01-07 11:00WFMRX
10002021-01-08 12:00ORTS 
10002021-01-09 10:45SCHD 
10002021-01-10 14:00TECO 
10002021-01-10 16:00CLSD 
100012021-01-01 8:00CRTD 
100012021-01-01 10:00INPL 
100012021-01-01 14:00PLND 
100012021-01-01 15:00WFMR 
100012021-01-04 16:00WFMRX
100012021-01-04 18:00ORTS 
100012021-01-04 20:00INPL 
100012021-01-05 22:00PLND 
100012021-01-05 0:00WFMR 
100012021-01-06 2:00WFMRX
100012021-01-06 14:00TECO 
100012021-01-06 16:00CLSD 

 

Thanks,

Mannu

2 REPLIES 2
lbendlin
Super User
Super User

So X means "negate the previous entry"?  

 

Your timestamps are not unique, so the sort order cannot be guaranteed. You need to add an index column.

 

What should order 1000 be on 2021-01-07 ?  CRTD,INPL,PLND,PLND ? 

What is the cutoff time for each date? beginning or end of day?

Yes... X means closure of previous entry with same status code.

True.. time stamps are not unique and multiple system status codes can have the same date time.  Its fine even if order cannot be guaranteed. It is fine as long as it is sorted by date time when using CONCATENATEX ..etc

 

Snapshot captures the active statuses at the end of previous day.

Output for 1000 as on 2021-01-07 would be CRTD,INPL,WFMR  (PLND is closed on 5th and hence shouldn't be considered).

As on 2021-01-08 it would be CRTD, INPL (as both PLND and WFMR are closed)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.