Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello community,
I wish to calculate the sum of the entire last month that is selected by a date slider.
Hence if December has 100 Sales and Novemeber 200 Sales and you adjust the date slider:
I have attempted a few approaches, one of which looked like this. The result werent very pleasing.
Sum Sales Last Month from Slider = CALCULATE( [Sales]; DATESINPERIOD( 'Date-Table'[Date] ; LASTDATE( 'Date-Table'[Date] ); STARTOFMONTH( LASTDATE( 'Date-Table'[Date] ));MONTH ))
Solved! Go to Solution.
Hi @raymond ,
For your requirement, you could try the measures below.
total sale each month = CALCULATE ( SUM ( 'data'[Revenue] ), ALLEXCEPT ( data, 'data'[Date].[Month], data[Date].[Year] ) ) Sum of entire selected (last) month = VAR maxdate = MONTH ( MAX ( 'data'[Date] ) ) RETURN CALCULATE ( [total sale each month], FILTER ( ALLSELECTED ( data ), MONTH ( 'data'[Date] ) = maxdate && YEAR ( 'data'[Date] ) = YEAR ( MAX ( 'data'[Date] ) ) ) )
Here is the output.
More details, please refer to my attachment.
Best Regards,
Cherry
@raymond sorry your request is not fully clear
You asked sum of last month and based on your examples below it suppose to be different result
Last month for following 1-3 items would be November, isn't it? and result would be 200 and for item #4 last month will be october and no previous month sales based on your example data of nov and dec.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
I guess the terms I used have room for interpretation.
You are absolutely right. I am looking for the sum of the selected end month. Perhaps this image will clarify my request 🙂
Hi @raymond ,
For your requirement, you could try the measures below.
total sale each month = CALCULATE ( SUM ( 'data'[Revenue] ), ALLEXCEPT ( data, 'data'[Date].[Month], data[Date].[Year] ) ) Sum of entire selected (last) month = VAR maxdate = MONTH ( MAX ( 'data'[Date] ) ) RETURN CALCULATE ( [total sale each month], FILTER ( ALLSELECTED ( data ), MONTH ( 'data'[Date] ) = maxdate && YEAR ( 'data'[Date] ) = YEAR ( MAX ( 'data'[Date] ) ) ) )
Here is the output.
More details, please refer to my attachment.
Best Regards,
Cherry
User | Count |
---|---|
141 | |
113 | |
104 | |
77 | |
64 |
User | Count |
---|---|
135 | |
123 | |
101 | |
71 | |
61 |