The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Want to be able to select a month on a slicer, then the measure caculates the last 3 months sales from the month selected. So for example if I selected Feb 24 on the slicer, I want to see sales from November 2023 to January 2024.
Any ideas?
Have been using the below which worked when looking at the last date of sales, but now we want to go back and look at previous months to make comparisons.
Solved! Go to Solution.
Hi @AIDA_User ,
Have you tried Ashish's suggestions?
I'm assuming your slicer is at the day level. Please create a new unjoined date table for the slicer and then create this measure:
Sales L3months =
VAR __slicer_date = MAX('Date'[Date])
VAR __max_date = EOMONTH(__slicer_date,-1) + 1
VAR __min_date = EDATE(__max_date,-3)
VAR __result = CALCULATE(SUM('Customer_Sales'[Invoice_Quantity]),'Customer_Sales'[Invoice_Date]>=__min_date && 'Customer_Sales'[Invoice_Date]<__max_date)
RETURN
__result
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum -- China Power BI User Group
Hi @AIDA_User ,
Step 1 :
In date table to create previous month column.
Step 2 :
Create duplicate date table to relate with date table then create the below measure.
Result:
If I select any month in slicer, values showing from previous month to last 3 month sales.
Best Regards,
Ajith Kumar
Did I answer your question? Mark my post as a solution!
Hi Ajith
I have been working through each suggestion and so far no good. I have now followed your steps and the below error has come up, please note I followed these steps:
Any ideas?
Hi @AIDA_User ,
Please create duplicate date table and create inactive relation between date to duplicate date table and use userelationship between both table. please refer my DAX.
Regards,
AjithKumar
Hi there,
I have done this. Still having issues. I have created a date table with inactive relationship. Still haveing issue.
To confirm your results you go and the view is exactly what I am looking for.
Hi @AIDA_User ,
Have you tried Ashish's suggestions?
I'm assuming your slicer is at the day level. Please create a new unjoined date table for the slicer and then create this measure:
Sales L3months =
VAR __slicer_date = MAX('Date'[Date])
VAR __max_date = EOMONTH(__slicer_date,-1) + 1
VAR __min_date = EDATE(__max_date,-3)
VAR __result = CALCULATE(SUM('Customer_Sales'[Invoice_Quantity]),'Customer_Sales'[Invoice_Date]>=__min_date && 'Customer_Sales'[Invoice_Date]<__max_date)
RETURN
__result
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum -- China Power BI User Group
This worked! Thank you! Now when I select the month on the slicer, it brings me the last 3 months.
Thank you
Hi there, thank you for your time and help.
Confirming my slicer is at month level, just year and month in the slicer.
So I have created a second table, it is a duplicate of the 1st table, I dont have a separate table for dates. All of our data, sales, customer, invoice, sku, dates are in one table.
So I created a second table named Customer_Sales (2).
Then I went back to the original table Customer_Sales and created this measure:
Hi,
I am n ot very sure of what you want. Try this
Total = SUM(Customer_Sales[Invoice_Quantity])
Sales in 3 months ended = calculate([Total],datesbetween(calendar[date],edate(min(calendar[date]),-2),max(calendar[date])))
Hope this helps.