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
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.LeanAndPractise(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.LeanAndPractise(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.LeanAndPractise(Everyday)


)



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.

Top Solution Authors