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.
I attempted to follow this thread on this channel but I think my issue is easier.
I have the below table (dates) that shows the beginning and ending of a month
StartDate | EndDate |
01/10/2020 | 31/10/2020 |
01/11/2020 | 30/11/2020 |
My other table (sales) has a date between these ranges
Date | Amount | Store |
08/10/2020 | 88 | StoreA |
11/10/2020 | 92 | StoreB |
05/11/2020 | 110 | StoreA |
I would like a date slicer that returns the sum based on filtered data in table (Sales)
Q1. Would it best to use a SUMX aggregrator?
Q2. How could I create a relationship between these two tables based only on the daterange?
I am a little stuck and would appreciate the help.
Solved! Go to Solution.
Hi @Anonymous,
You don't need a table with start and end. You can create just a date table and relate them.
Use a slicer, you are gonna have the start/end dates to filter. Also, you can create more columns on your date table like month/year and use it on slicers.
Check this file: Download PBIX
Did I answer your question? Mark my post as a solution!
Ricardo
Hi @Anonymous ,
This is just an example, there are many ways to create the date table.
Ricardo
Hi @Anonymous,
You don't need a table with start and end. You can create just a date table and relate them.
Use a slicer, you are gonna have the start/end dates to filter. Also, you can create more columns on your date table like month/year and use it on slicers.
Check this file: Download PBIX
Did I answer your question? Mark my post as a solution!
Ricardo
Thanks for the help on this one. It was driving me a bit mad.
Can I check the process you did to create the Date Table? I want to recycle your code e.g.
Date = CALENDAR(EOMONTH(MIN(Sales[Date]). -1) +1, EOMONTH(MAX(Sales[Date]), 0))
Thank you
Hi @Anonymous,
Sure.
The function CALENDAR receives 2 parameters (start and end dates), the code just get the min and max of your sales date and the function EOMONTH returns the end of the month with the number of months you need.
Example:
EOMONTH(MIN(Sales[Date]). -1) +1
This one goes to the end of the min month of your sales tables, but the parameter is -1, so it will go back 1 month. Also it's adding 1 day to this date.
Min Date => 2020-01-01
EOMONTH => 2020-01-31 // This is the same as EOMONTH(MIN(Sales[Date]); -0))
EOMONTH with -1 => 2019-12-31
(EOMONTH with -1) + 1 => 2019-12-31 + 1 => 2020-01-01
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://docs.microsoft.com/en-us/dax/calendar-function-dax
Also check this link for time-intel functions, you can enrich you report with them:
https://docs.microsoft.com/en-us/dax/time-intelligence-functions-dax
Ricardo
Thanks Ricardo.
What is the best way to create the data table? Do I just press the entre data option in the Home>Data icon?
Can you share the steps you did to create this data table. This was what I was trying to ask. Sorry I was not clear.
Thanks for those articles I will ingest them 🙂
Oh I think you shared that article https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
Can you share that code snippet?
User | Count |
---|---|
24 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
29 | |
11 | |
11 | |
9 | |
9 |