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
renan_arrieiro
Frequent Visitor

How to summarize with SUMMARIZECOLUMNS the last 4 invoices of each client

Hi guys,

I have a table with columns:

ShopCustomerDateValue
C113764310/01/20196240
C113764323/01/20191473,52
CD1275022/01/20191053,02
CD13301519/02/2019598,78
C114069612/02/2019503,48
C114069614/02/2019446,65
C114069624/01/2019322,45
............


for each customer purchase.

 

I need a table summarized with the last 4 invoices of each client, example result:

Shop
CustomerDateValue
C113764310/01/20191.000,00
C113764323/01/20191.500,00
C113764316/12/20182.658,00
C113764308/11/20182.036,00
CD1275005/02/2019100,00
CD1275010/01/2019233,00
CD1275007/11/201850,00
CD1275015/10/201888,00

 

I've been trying all morning.

 

Thanks for all help.

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @renan_arrieiro 

You may create a rank column for the table.Then create a table with SUMMARIZE Function to get the last 4 invoices of each client.

Rank = RANKX(FILTER(Table2,Table2[Customer]=EARLIER(Table2[Customer])),Table2[Date],,DESC)
New Table =
SUMMARIZE (
    FILTER ( Table2, Table2[Rank] <= 4 ),
    Table2[Shop],
    Table2[Customer],
    Table2[Date],
    Table2[Value]
)

1.png

Regards

Community Support Team _ Cherie Chen
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

2 REPLIES 2
v-cherch-msft
Employee
Employee

Hi @renan_arrieiro 

You may create a rank column for the table.Then create a table with SUMMARIZE Function to get the last 4 invoices of each client.

Rank = RANKX(FILTER(Table2,Table2[Customer]=EARLIER(Table2[Customer])),Table2[Date],,DESC)
New Table =
SUMMARIZE (
    FILTER ( Table2, Table2[Rank] <= 4 ),
    Table2[Shop],
    Table2[Customer],
    Table2[Date],
    Table2[Value]
)

1.png

Regards

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks very much for your time @v-cherch-msft,


with some adjustments worked perfectly,


Rank column:

 

RANKX(
  FILTER(
    F_FATURA;
    F_FATURA[CLIENTE] = EARLIER(F_FATURA[CLIENTE]) && //CUSTOMER
    F_FATURA[CANAL]   = EARLIER(F_FATURA[CANAL]) //SHOP
  );
  F_FATURA[DATA_FATURAMENTO]; //DATE
  ;
  DESC;
  DENSE
)


new table:

F_ULTIMAS_FATURAS = 
SUMMARIZECOLUMNS(
    F_FATURA[CANAL]; //SHOP
    F_FATURA[CLIENTE]; //CUSTOMER
    F_FATURA[DATA_FATURAMENTO]; //DATE
    F_FATURA[RANK_DATA]; //RANK
    FILTER ( F_FATURA; F_FATURA[RANK_DATA] <= 4 ) //FILTER
)

Thanks thanks.

 

now I'm going to the next part

 

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.