Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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:
Regards
Rodrigo P.
Solved! Go to Solution.
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
Regards
sanalytics
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
Regards
sanalytics
Isn't that exactly the same answer that @Joe_Barry gave?
Phil
Proud to be a Super User!
yes. i did also the same thing.. After i posted, i see Joe's solution
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])
)
Hope this helps
Joe
Proud to be a Super User! | |
Date tables help! Learn more
Hello, I hope I understood your request correctly
Sum3LastMonths =
VAR CurrentDate = 'YourTable'[Fecha]
RETURN
CALCULATE(
SUM('YourTable'[Valor]),
DATESINPERIOD('YourTable'[Fecha], CurrentDate, -3, MONTH)
)
User | Count |
---|---|
25 | |
10 | |
7 | |
6 | |
6 |
User | Count |
---|---|
30 | |
11 | |
11 | |
9 | |
7 |