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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
khaeshr46
Frequent Visitor

Sum of Max Date for each each month

Hi,

I am looking to create a DAX formula to get the Total Sales of max date of each month for Scenario = "Actual", and Category = "Applicances".

 

Thanks!

 

Sample Data:

DateCategoryScenarioCustomerTotal Sales
4/26/2013BookcasesPlanAdam Bellavance6548.5
4/26/2013BookcasesPlanAdam Bellavance2153.55
4/26/2013AppliancesActualAdam Bellavance2472.66
11/7/2014TablesPlanAdam Bellavance1516.84
11/7/2014TablesPlanAdam Bellavance2036.86
11/7/2014TablesActualAdam Bellavance1565.12
11/26/2014TablesPlanAdam Bellavance1237.56
11/26/2014AppliancesPlanAdam Bellavance548.56
11/26/2014AppliancesActualAdam Bellavance367.67

 

Required Output

4/26/2013AppliancesActualAdam Bellavance2472.66
11/26/2014AppliancesActualAdam Bellavance367.67
    2840.33
1 ACCEPTED SOLUTION

 

Sum of Max Date for Each Month = 
SUMX(
    VALUES( DATA[Customer] ),
    SUMX(
        VALUES( DATA[Yr-Mth] ),
        VAR __tr = TREATAS( { ( "Appliances", "Actual" ) }, DATA[Category], DATA[Scenario] )
        VAR __max = CALCULATE( MAX( DATA[Date] ), KEEPFILTERS( __tr ), ALL( DATA[Date] ) )
        RETURN
            CALCULATE(
                SUM( DATA[Total Sales] ),
                KEEPFILTERS( DATA[Date] = __max ),
                __tr
            )
    )
)

 

ThxAlot_1-1697925834682.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

3 REPLIES 3
ThxAlot
Super User
Super User

ThxAlot_0-1697860987388.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



That's not quite what I am looking for.
 
Here's a measure breakdown for it but its not the right way at all. In this example its not Year focused. as taking in 2013 and 2014 dates in. But I would like for it to be year focused. Sum of Sales for each MONTH YEAR Scenario = "Actual", and Category = "Applicances".
 
Thanks alot! Really appriciate the help.
 
khaeshr46_0-1697905044743.png

 

khaeshr46_1-1697905044789.png

 

 

 

 
Measure =
var a =
CALCULATE(MAX(DATA[Date]),
DATA[Category] = "Appliances" && DATA[Scenario] = "Actual",
FILTER(DATA,DATA[Date] > DATE(2013,1,1) && DATA[Date] <= DATE(2013,12,31)))

var b =
CALCULATE(SUM(DATA[Total Sales]),
DATA[Category] = "Appliances" && DATA[Scenario] = "Actual",
FILTER(DATA,DATA[Date] = a))

var c =
CALCULATE(MAX(DATA[Date]),
DATA[Category] = "Appliances" && DATA[Scenario] = "Actual",
FILTER(DATA,DATA[Date] > DATE(2014,1,1) && DATA[Date] <= DATE(2014,12,31)))

var d =
CALCULATE(SUM(DATA[Total Sales]),
DATA[Category] = "Appliances" && DATA[Scenario] = "Actual",
FILTER(DATA,DATA[Date] = c))


Return  b+d

 

Sum of Max Date for Each Month = 
SUMX(
    VALUES( DATA[Customer] ),
    SUMX(
        VALUES( DATA[Yr-Mth] ),
        VAR __tr = TREATAS( { ( "Appliances", "Actual" ) }, DATA[Category], DATA[Scenario] )
        VAR __max = CALCULATE( MAX( DATA[Date] ), KEEPFILTERS( __tr ), ALL( DATA[Date] ) )
        RETURN
            CALCULATE(
                SUM( DATA[Total Sales] ),
                KEEPFILTERS( DATA[Date] = __max ),
                __tr
            )
    )
)

 

ThxAlot_1-1697925834682.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.