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
toinktoink
New Member

DAX Measure for Audit Log

 

I have a table thats almos tan audit log table. An order only gets a record for a particular date if the status of the order changes. I want to summarize the number of orders for each status by date. I know how to do this through a calculated table, but trying to do it as a measure:

 

 

table.PNG

 

For example, Order '234' does not show up for 2/1/2018 because it's status was not changed. But in my measure, when I summaruze orders by status for 2/1/2018, I want this order to show up under the 'Open' status because that was the latest status for this order.

 

Looking for ideas!

1 ACCEPTED SOLUTION

@toinktoink

 

It seemingly works with your sample data.

Please see the attached file as well.

 

log.png 


Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4

Hi,

 

please share a sample data model. The code is not hard to author, but it will be slow... that said, unless you have tens of millions of rows this should not be an issue.

 


Have fun with DAX!

Alberto Ferrari
http://www.sqlbi.com

Alberto Ferrari - SQLBI
toinktoink
New Member

Hi I have a table, almost an audit log, where only those orders are repeated where the status is changed. I want to have a measure that can tell me the count of orders by status for any date. I know how to do it in a separate calculated table but trying to see if I can do it as a measure:

 

 

Please note that Order '234' does not show up for 2/1/2018 because it's status has not changed. But when I do a sum of all status as of 2/1/2018, I want this order to be included in the 'Open' count since that was the latest status.

@toinktoink

 

Try this MEASURE.

 

Measure =
VAR temp1 =
    SUMMARIZE (
        FILTER ( ALLSELECTED ( Table1 ), Table1[Date] <= SELECTEDVALUE ( Table1[Date] ) ),
        Table1[OrderID],
        "Last Status", CALCULATE ( VALUES ( Table1[Status] ), LASTDATE ( Table1[Date] ) )
    )
VAR mystatus =
    SELECTEDVALUE ( Table1[Status] )
RETURN
    COUNTX ( FILTER ( temp1, [Last Status] = mystatus ), [OrderID] )

Regards
Zubair

Please try my custom visuals

@toinktoink

 

It seemingly works with your sample data.

Please see the attached file as well.

 

log.png 


Regards
Zubair

Please try my custom visuals

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.