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
GoblinKingdom
Employee
Employee

Group if created within 72 hours

Hello,

I am attempting  group my table of IncomingWork items by CustomerID as well as if they have been created within 72hours from the earliest entry. I have created the sample table with data below and how the items should be counted.

 

GoblinKingdom_2-1622641254644.png

 

The end result should have CustomerID 1001 have a total of 2 items, and 2001 a total of 1 item. 

I am not familiar enough with DAX functions to complete this, is anyone able to assist me?

 

Thank you in advance. 

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ndAxDsAgCEDRuzBrghhsO7bXMN7/Gg52qd/BdH0DfKhVbgliaimqx5SlhYlOkCnJt6iQOD5z/IrSRCXqoIcH/SAnlS06SBfofeGHWG/sWhFTjV2ZG1c0R4yvtg4=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CustomerID = _t, Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"CustomerID", type text}, {"Date", type date}}),
    #"Grouped Rows" = Table.RemoveColumns(Table.Group(#"Changed Type", {"CustomerID"}, {{"ar", each Table.AddIndexColumn(Table.Group(_, "Date", {"All", each _}, 0, (x,y) => Number.From(Duration.Days(y-x)>=3)),"Index",1)}}), "CustomerID"),
    #"Expanded ar" = Table.RemoveColumns(Table.ExpandTableColumn(#"Grouped Rows", "ar", {"Date", "All", "Index"}, {"Date", "All", "Index"}), "Date"),
    #"Expanded All" = Table.ExpandTableColumn(#"Expanded ar", "All", {"CustomerID", "Date"}, {"CustomerID", "Date"})
in
    #"Expanded All"

Screenshot 2021-06-02 164431.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Thank you for the quick reply. I apologize though, I meant to ask this for in a Measure format.

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.