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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Goossensm
New Member

Summarise table but repeat values which are zero

Hi all,

 

I have a transactions table which I would like to summarise in such way, so I can define and fix a label (ABC) per customer for each month, based on the last twelve months turnover via the rank and cumulative % function. 

 

A customer = within first 80% of turnover, ranked by sales per customer on LTM basis

B customer = within 15% of turnover, ranked by sales per customer on LTM basis

C customer = within 5% of turnover, ranked by sales per customer on LTM basis

 

I have a separate calendar table which is linked to the transactions table.

 

Transactions table:

Invoice date

YearMonth

(invoice date)

Customer Turnover

ABC

label

01/03/2020Mar20Customer 1 40 
15/03/2020Mar20Customer 2 30 
15/04/2020Apr20Customer 1 20 
26/05/2020May20Customer 3 40 
14/06/2020Jun20Customer 2 30 
      

 

I would like to summarise the transaction table as follows:

YearMonthCustomer

 

LTM

turnover

customer

LTM

turnover

total 

% of

LTM

turnover

total

rankcumulative
Mar20Customer 1 407057%157%
Mar20Customer 2 307043%2100%
Mar20Customer 3 0700%3100%
Apr20Customer 1 609066%166%
Apr20Customer 2 309034%2100%
Apr20Customer 3 0900%30%
May20Customer 1 6013046%146%
May20Customer 2 3013023%3100%
May20Customer 3 4013031%277%
Jun20Customer 1 6016037%137%
Jun20Customer 2 6016037%274%
Jun20Customer 3 4016026%3100%

 

Then I would define a label for each customer for each month, based on the LTM turnover.

I would then use a 'lookupvalue' function to add the label in a new column into the transaction table.

 

But when I use a regular summarise or groupby function I only get the customers for a specific month, when the turnover in that month is not 0, when I actually need to repeat all customers for all months.

 

Thanks in advance for the help!

 

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @Goossensm 

 

According to your description, I made a sample. 

You need to create a YM column for sort in fact table, then create a new table with these columns and measures.

Like this:

YM = YEAR('Table'[Invoice date])*100+MONTH('Table'[Invoice date])
Table 2 = CROSSJOIN(DISTINCT('Table'[Customer]),DISTINCT('Table'[YM]))
Turnovercopy = 
SUMX (
    FILTER (
        ALL ( 'Table' ),
        [YM] = EARLIER ( 'Table 2'[YM] )
            && [Customer] = EARLIER ( 'Table 2'[Customer] )
    ),
    [Turnover]
)
Column 2 = 
VAR a =
    SUMX (
        FILTER (
            ALL ( 'Table 2' ),
            [Customer] = EARLIER ( 'Table 2'[Customer] )
                && [YM] <= EARLIER ( 'Table 2'[YM] )
        ),
        [Turnovercopy]
    )
RETURN
    IF ( a <> BLANK (), a, 0 )
Column 3 = 
SUMX (
    FILTER ( ALL ( 'Table 2' ), [YM] = EARLIER ( 'Table 2'[YM] ) ),
    [Column 2]
)
Column 4 = DIVIDE([Column 2],[Column 3])
Column 5 = 
RANKX (
    FILTER ( ALL ( 'Table 2' ), [YM] = EARLIER ( 'Table 2'[YM] ) ),
    'Table 2'[Column 4],
    ,
    DESC,
    SKIP
)
Measure5 = 
SUMX (
    FILTER (
        ALL ( 'Table 2' ),
        [YM] = SELECTEDVALUE ( 'Table 2'[YM] )
            && [Column 5] <= SELECTEDVALUE ( 'Table 2'[Column 5] )
    ),
    [Column 4]
)

8.png

Here is my sample file. Hope it helps.

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

3 REPLIES 3
v-janeyg-msft
Community Support
Community Support

Hi, @Goossensm 

 

According to your description, I made a sample. 

You need to create a YM column for sort in fact table, then create a new table with these columns and measures.

Like this:

YM = YEAR('Table'[Invoice date])*100+MONTH('Table'[Invoice date])
Table 2 = CROSSJOIN(DISTINCT('Table'[Customer]),DISTINCT('Table'[YM]))
Turnovercopy = 
SUMX (
    FILTER (
        ALL ( 'Table' ),
        [YM] = EARLIER ( 'Table 2'[YM] )
            && [Customer] = EARLIER ( 'Table 2'[Customer] )
    ),
    [Turnover]
)
Column 2 = 
VAR a =
    SUMX (
        FILTER (
            ALL ( 'Table 2' ),
            [Customer] = EARLIER ( 'Table 2'[Customer] )
                && [YM] <= EARLIER ( 'Table 2'[YM] )
        ),
        [Turnovercopy]
    )
RETURN
    IF ( a <> BLANK (), a, 0 )
Column 3 = 
SUMX (
    FILTER ( ALL ( 'Table 2' ), [YM] = EARLIER ( 'Table 2'[YM] ) ),
    [Column 2]
)
Column 4 = DIVIDE([Column 2],[Column 3])
Column 5 = 
RANKX (
    FILTER ( ALL ( 'Table 2' ), [YM] = EARLIER ( 'Table 2'[YM] ) ),
    'Table 2'[Column 4],
    ,
    DESC,
    SKIP
)
Measure5 = 
SUMX (
    FILTER (
        ALL ( 'Table 2' ),
        [YM] = SELECTEDVALUE ( 'Table 2'[YM] )
            && [Column 5] <= SELECTEDVALUE ( 'Table 2'[Column 5] )
    ),
    [Column 4]
)

8.png

Here is my sample file. Hope it helps.

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

amitchandak
Super User
Super User

@Goossensm , Are you looking for segmentation or binning (bucket on the measure)

https://www.daxpatterns.com/abc-classification/

 

Or check this -https://www.youtube.com/watch?v=CuczXPj0N-k

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak ,

 

The first link is already very helpful.

I am indeed looking for a snapshot abc classiciation for the customers. 

But instead of calculating it again each year, I would like to take a snapshot each month, and classify each customer for that specific month based on the last twelve months sales.

Kr,

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors