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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Grouping transactions by number of days

Hello,

 

I need to group transactions by specific number of days after that point. For example number of transac tions between the 3rd-5th day, the 6th-15th day and so on. Can someone please help me figure out the formula for this

Thank you!

 

CamilaPenaranda_2-1661798785347.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

Here are the steps you can follow:

1. Check the yellow column – Transform – Unpivot Columns.

vyangliumsft_0-1661996201670.png

2. Select the new [Atrribute] – convert its format to Date/Time.

vyangliumsft_1-1661996201674.png

3. Create calculated table.

Table 2 =
SUMMARIZE('Table','Table'[Name],
"1-2days",
SUMX(FILTER(ALL('Table'),'Table'[Name]=EARLIER('Table'[Name])&&
'Table'[Attribute]>=
MINX(ALL('Table'),'Table'[Attribute])&&'Table'[Attribute]<=MINX(ALL('Table'),'Table'[Attribute])+1),[Value]),
"3-5days",
SUMX(FILTER(ALL('Table'),'Table'[Name]=EARLIER('Table'[Name])&&
'Table'[Attribute]>=
MINX(ALL('Table'),'Table'[Attribute])+2&&'Table'[Attribute]<=MINX(ALL('Table'),'Table'[Attribute])+6),[Value]))

4. Result:

vyangliumsft_2-1661996201674.png

 

If you need pbix, please click here.

Grouping transactions by number of days.pbix

 

Best Regards,

Liu Yang

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  @Anonymous ,

Here are the steps you can follow:

1. Check the yellow column – Transform – Unpivot Columns.

vyangliumsft_0-1661996201670.png

2. Select the new [Atrribute] – convert its format to Date/Time.

vyangliumsft_1-1661996201674.png

3. Create calculated table.

Table 2 =
SUMMARIZE('Table','Table'[Name],
"1-2days",
SUMX(FILTER(ALL('Table'),'Table'[Name]=EARLIER('Table'[Name])&&
'Table'[Attribute]>=
MINX(ALL('Table'),'Table'[Attribute])&&'Table'[Attribute]<=MINX(ALL('Table'),'Table'[Attribute])+1),[Value]),
"3-5days",
SUMX(FILTER(ALL('Table'),'Table'[Name]=EARLIER('Table'[Name])&&
'Table'[Attribute]>=
MINX(ALL('Table'),'Table'[Attribute])+2&&'Table'[Attribute]<=MINX(ALL('Table'),'Table'[Attribute])+6),[Value]))

4. Result:

vyangliumsft_2-1661996201674.png

 

If you need pbix, please click here.

Grouping transactions by number of days.pbix

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

Thank you!!

Anonymous
Not applicable

Below an example of the data set.

Name9/25/20229/26/20229/27/20229/28/20229/29/20229/30/202210/1/2022

Name

1

           3456789

Name

2

           2345678

Name

3

             567891011

Result I am looking for

Name1-2 days (9/25-9/26)3-5 days(9/27-10/1)

Name

1

                     735

Name

2

                530

Name

3

               1145

Table Fields

Date

Name

Transactions

 

I used a matrix and tried grouping by the switch function but it didn't aggregate values correctly when I picked the day I wanted it to start counting from

Day Grouping =

 SWITCH(TRUE(),

 AND(DATEDIFF(Table[Date],Today(),DAY)>=1,

 DATEDIFF(Source[Table[Date],Today(),DAY) <=2), "1-2",

 

AND(DATEDIFF(Table[Date],Today(),DAY)>=3,

 DATEDIFF(Source[Table[Date],Today(),DAY) <=6), "3-6",

 

AND(DATEDIFF(Source[Table[Date],Today(),DAY)>=6,

 DATEDIFF(Source[Table[Date],Today(),DAY) <=15), "6-15",

 

AND(DATEDIFF(Source[Table[Date],Today(),DAY)>=16,

 DATEDIFF(Source[Table[Date],Today(),DAY) <=22), "16-22",

 

 AND(DATEDIFF(Source[Table[Date],Today(),DAY)>=23,

 DATEDIFF(Source[Table[Date],Today(),DAY) <=29), "23-29",

 

AND(DATEDIFF(Source[Table[Date],Today(),DAY)>=30,

 DATEDIFF(Source[Table[Date],Today(),DAY) <=60), "30-60")

 

Thank you

PijushRoy
Super User
Super User

@Anonymous 

Please share the sample data 





Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.