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.
Hi , i have a sample data below.
How can I use DAX to get the below result?
I want to get the total sales in of pervious three months.
Jan=Jan,
Feb=Jan+Feb
Mar=Jan+Feb+Mar
....
Sep=Jul+Aug+Sep
Thanks in advanced.
Proud to be a Super User!
Solved! Go to Solution.
@ryan_mayu Here is the measure for same...
Test46Out = CALCULATE(SUM(Test46CummSum[Value]),FILTER(ALL(Test46CummSum),Test46CummSum[Date] <= MAX(Test46CummSum[Date]) && YEAR(Test46CummSum[Date]) = YEAR(MAX(Test46CummSum[Date])) && DATEDIFF(Test46CummSum[Date],MAX(Test46CummSum[Date]),MONTH)<=2 ))
Proud to be a PBI Community Champion
@ryan_mayu Please try this as a "New Table"
Test46Out = VAR _Temp = ADDCOLUMNS(Test46CummSum,"CummSum",CALCULATE(SUM(Test46CummSum[Value]),FILTER(Test46CummSum,Test46CummSum[Date]<=EARLIER(Test46CummSum[Date]) && DATEDIFF(Test46CummSum[Date],EARLIER(Test46CummSum[Date]),MONTH)<=2 ))) RETURN SELECTCOLUMNS(_Temp,"Month",[Month],"Total",[CummSum])
Proud to be a PBI Community Champion
thanks for your help. Is it possible to create a measure to draw a chart by month?
Proud to be a Super User!
@ryan_mayu Here is the measure for same...
Test46Out = CALCULATE(SUM(Test46CummSum[Value]),FILTER(ALL(Test46CummSum),Test46CummSum[Date] <= MAX(Test46CummSum[Date]) && YEAR(Test46CummSum[Date]) = YEAR(MAX(Test46CummSum[Date])) && DATEDIFF(Test46CummSum[Date],MAX(Test46CummSum[Date]),MONTH)<=2 ))
Proud to be a PBI Community Champion
Can I escalate this question?
I read your DAX, it works in a year. What about Jan 2019= Nov 2018+Dec 2018+Jan 2019?
Do you have any idea on how to solve this problem?
Proud to be a Super User!
@ryan_mayu Yes, Ofcourse !! In that case, try the same DAX by removing the YEAR condition in the FILTER.
Proud to be a PBI Community Champion
@PattemManohar, I will try that. Thanks a lot.
Proud to be a Super User!
Thanks, it works.
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |