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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
av9
Helper III
Helper III

Sum values by category when available in dataset with different months

Hi, I have a scenario where I am trying to calculate the total amount per customer. My data is received in the following format. Each month I get a Total Amount per category per customer, and the Total is static, i.e I dont need to have a running total, I just take the value for each month.

 

DateCustomerCategoryTotal Amount
30/08/2020AWeb$100
30/08/2020AMobile$0
30/08/2020BWeb$100
30/08/2020BMobile$100
30/09/2020AWeb$500
30/09/2020AMobile$500

 

So when I look at the data today I want the Totals for each customer to be: 

Combined Total @ Today 
Customer A$1000 
Customer B$200As I haven't got the Sep 2020 data for customer B the total stays as per Aug 2020.

 

Next day: I refresh data and it looks like this: 

 

DateCustomerCategoryTotal Amount
30/08/2020AWeb$100
30/08/2020AMobile$0
30/08/2020BWeb$100
30/08/2020BMobile$100
30/09/2020AWeb$500
30/09/2020AMobile$500
30/09/2020BWeb$200

 

So Total per Customer will be: 

Combined Total @ Today
A$1,000 
B$300this is made up of $200(Web-Sep2020) + $100(Mobile-Aug2020)

 

And so on it goes. once the Mobile data for September comes through I then replace the August mobile data

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@av9,

Try this measure:

Amount = 
VAR vMobileRows =
    FILTER ( Test1, Test1[Category] = "Mobile" )
VAR vMobileMaxDate =
    MAXX ( vMobileRows, Test1[Date] )
VAR vMobileLatestRow =
    FILTER ( vMobileRows, Test1[Date] = vMobileMaxDate )
VAR vMobileAmount =
    SUMX ( vMobileLatestRow, Test1[Total Amount] )
VAR vWebRows =
    FILTER ( Test1, Test1[Category] = "Web" )
VAR vWebMaxDate =
    MAXX ( vWebRows, Test1[Date] )
VAR vWebLatestRow =
    FILTER ( vWebRows, Test1[Date] = vWebMaxDate )
VAR vWebAmount =
    SUMX ( vWebLatestRow, Test1[Total Amount] )
VAR vResult = vMobileAmount + vWebAmount
RETURN
    vResult

Today:

DataInsights_0-1602793726964.png

The next day:

DataInsights_1-1602793741531.png





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@av9,

Try this measure:

Amount = 
VAR vMobileRows =
    FILTER ( Test1, Test1[Category] = "Mobile" )
VAR vMobileMaxDate =
    MAXX ( vMobileRows, Test1[Date] )
VAR vMobileLatestRow =
    FILTER ( vMobileRows, Test1[Date] = vMobileMaxDate )
VAR vMobileAmount =
    SUMX ( vMobileLatestRow, Test1[Total Amount] )
VAR vWebRows =
    FILTER ( Test1, Test1[Category] = "Web" )
VAR vWebMaxDate =
    MAXX ( vWebRows, Test1[Date] )
VAR vWebLatestRow =
    FILTER ( vWebRows, Test1[Date] = vWebMaxDate )
VAR vWebAmount =
    SUMX ( vWebLatestRow, Test1[Total Amount] )
VAR vResult = vMobileAmount + vWebAmount
RETURN
    vResult

Today:

DataInsights_0-1602793726964.png

The next day:

DataInsights_1-1602793741531.png





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors