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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
GFire
Helper I
Helper I

Tabular measure.

Hi,

 

I need help with this measure:

 

Create a measure that sums the total cumulative sales of all customers who had no sales last year.

For this table, customers A and C had no sales last year, so the measure should result in 1699.66 (1539.24 + 160.42).

 

GFire_0-1748431233943.png

 

Thanks

1 ACCEPTED SOLUTION

You need to also filter out the rows where sales is 0

Cumulative Sales No Sales Last Year] =
VAR AllCustomers =
    CALCULATETABLE ( DISTINCT ( 'Table'[Customer] ), REMOVEFILTERS () )
VAR PrevYear =
    YEAR ( TODAY () ) - 1
VAR CustomersWithSalesLastYear =
    CALCULATETABLE ( DISTINCT ( 'Table'[Customer] ), 'Table'[Year] = PrevYear, 'Table'[Sales] > 0 )
VAR CustomersNoSalesLastYear =
    EXCEPT ( AllCustomers, CustomersWithSalesLastYear )
VAR Result =
    CALCULATE ( SUM ( 'Table'[Sales] ), CustomersNoSalesLastYear )
RETURN
    Result

View solution in original post

5 REPLIES 5
johnt75
Super User
Super User

You can try

Cumulative Sales No Sales Last Year =
VAR AllCustomers =
    CALCULATETABLE ( DISTINCT ( 'Table'[Customer] ), REMOVEFILTERS () )
VAR PrevYear =
    YEAR ( TODAY () ) - 1
VAR CustomersWithSalesLastYear =
    CALCULATETABLE ( DISTINCT ( 'Table'[Customer] ), 'Table'[Year] = PrevYear )
VAR CustomersNoSalesLastYear =
    EXCEPT ( AllCustomers, CustomersWithSalesLastYear )
VAR Result =
    CALCULATE ( SUM ( 'Table'[Sales] ), CustomersNoSalesLastYear )
RETURN
    Result

the measure should result in 1699.66 (1539.24 + 160.42).

 

01.png

You need to also filter out the rows where sales is 0

Cumulative Sales No Sales Last Year] =
VAR AllCustomers =
    CALCULATETABLE ( DISTINCT ( 'Table'[Customer] ), REMOVEFILTERS () )
VAR PrevYear =
    YEAR ( TODAY () ) - 1
VAR CustomersWithSalesLastYear =
    CALCULATETABLE ( DISTINCT ( 'Table'[Customer] ), 'Table'[Year] = PrevYear, 'Table'[Sales] > 0 )
VAR CustomersNoSalesLastYear =
    EXCEPT ( AllCustomers, CustomersWithSalesLastYear )
VAR Result =
    CALCULATE ( SUM ( 'Table'[Sales] ), CustomersNoSalesLastYear )
RETURN
    Result
bhanu_gautam
Super User
Super User

@GFire Create a calculated column to check if a customer had sales last year:

DAX
HadSalesLastYear =
VAR CurrentYear = 'Table'[Year]
VAR Customer = 'Table'[Customer]
VAR SalesLastYear =
CALCULATE(
SUM('Table'[totalSales]),
FILTER(
'Table',
'Table'[Customer] = Customer &&
'Table'[Year] = CurrentYear - 1
)
)
RETURN
IF(SalesLastYear > 0, 1, 0)

 

Create a measure to sum the total sales for customers who had no sales last year:

DAX
TotalCumulativeSalesNoSalesLastYear =
CALCULATE(
SUM('Table'[totalSales]),
FILTER(
'Table',
'Table'[HadSalesLastYear] = 0
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






the measure should result in 1699.66 (1539.24 + 160.42).

 

02.png

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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