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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
rod_puente
Helper I
Helper I

Help with DAX Columm

Dear All

 

Please I need help with a function in DAX as a column and not as a measure that shows the sum of the last 3 months. I have this example and the yellow column should be the result of a column function by DAX:

 

rod_puente_0-1726816568230.png

 

Regards

Rodrigo P.

 

1 ACCEPTED SOLUTION
sanalytics
Super User
Super User

@rod_puente 

Ultimos 3 Meses = 
VAR _MaxDate = 
CALCULATE(
    MAX( 'Table'[Date] ),
    ALLEXCEPT( 'Table', 'Table'[Product])
) 
VAR _Result = 
CALCULATE(
    SUM( 'Table'[Value] ),
    DATESINPERIOD( 'Table'[Date], _MaxDate,-3,MONTH )
    ,ALLEXCEPT( 'Table','Table'[Product] )
)
 
RETURN
_Result

sanalytics_0-1726821002382.png

Regards

sanalytics

View solution in original post

5 REPLIES 5
sanalytics
Super User
Super User

@rod_puente 

Ultimos 3 Meses = 
VAR _MaxDate = 
CALCULATE(
    MAX( 'Table'[Date] ),
    ALLEXCEPT( 'Table', 'Table'[Product])
) 
VAR _Result = 
CALCULATE(
    SUM( 'Table'[Value] ),
    DATESINPERIOD( 'Table'[Date], _MaxDate,-3,MONTH )
    ,ALLEXCEPT( 'Table','Table'[Product] )
)
 
RETURN
_Result

sanalytics_0-1726821002382.png

Regards

sanalytics

@sanalytics 

 

Isn't that exactly the same answer that @Joe_Barry  gave?

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


@PhilipTreacy 

yes. i did also the same thing.. After i posted, i see Joe's solution

Joe_Barry
Super User
Super User

Hi @rod_puente 

 

You can try this

Last 3 Months Sales = 
VAR _MaxDate = CALCULATE(MAX('Table'[Fecha]), ALLEXCEPT('Table', 'Table'[Producto]))

RETURN
CALCULATE (
    SUM('Table'[Valor]),
    DATESINPERIOD('Table'[Fecha], _MaxDate, -3, MONTH),
    ALLEXCEPT('Table', 'Table'[Producto])
)

Joe_Barry_0-1726819711848.png

 

Hope this helps

Joe




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

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn
Let's connect on LinkedIn


jkrumb
Regular Visitor

Hello, I hope I understood your request correctly

 

Sum3LastMonths =
VAR CurrentDate = 'YourTable'[Fecha]
RETURN
CALCULATE(
SUM('YourTable'[Valor]),
DATESINPERIOD('YourTable'[Fecha], CurrentDate, -3, MONTH)
)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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