Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi,
I have a table as below:
data_Date | Intramonth | Attribute | Value |
31/01/2020 | 31-Jan-20 | KIDS | 20% |
31/01/2020 | 31-Jan-20 | TEACHERS | 30% |
31/01/2020 | 31-Jan-20 | Admin Staff | 40% |
28/02/2020 | 28-Feb-20 | KIDS | 0.00% |
28/02/2020 | 28-Feb-20 | TEACHERS | 100% |
28/02/2020 | 28-Feb-20 | Admin Staff | 23% |
31/03/2020 | 31/03/2020 | KIDS | 40% |
31/03/2020 | 31/03/2020 | TEACHERS | 23% |
31/03/2020 | 31/03/2020 | Admin Staff | 45% |
30/04/2020 | 30/04/2020 | KIDS | 23% |
30/04/2020 | 30/04/2020 | TEACHERS | 67% |
30/04/2020 | 30/04/2020 | Admin Staff | 70% |
29/05/2020 | 29/05/2020 | KIDS | 56% |
29/05/2020 | 29/05/2020 | TEACHERS | 98% |
29/05/2020 | 29/05/2020 | Admin Staff | 35% |
30/06/2020 | 30/06/2020 | KIDS | 56% |
30/06/2020 | 30/06/2020 | TEACHERS | 34% |
30/06/2020 | 30/06/2020 | Admin Staff | 56% |
31/07/2020 | 31/07/2020 | KIDS | 67% |
31/07/2020 | 31/07/2020 | TEACHERS | 23% |
31/07/2020 | 31/07/2020 | Admin Staff | 45% |
My final output needs to have a datepicker which has all distinct dates. Based onn the date selected, it needs to display data for previous 4 months: In the screenshot below, I've selected 31/07/2020 in the date picker, so I get output for the previous 3 months. The selected date is displayed as intra-month
Intra-Month | 30/06/2020 | 29/05/2020 | 30/04/2020 | |
Kids | 67% | 56% | 56% | 23% |
If I select, 29/05/2020, I get the following results in the Kids table:
Intra-Month | 30/04/2020 | 31/03/2020 | 28-Feb-20 | |
Kids | 56% | 23% | 40% | 0% |
I've created a Date table to map the selected date to previous months using the Power BI query below:
Solved! Go to Solution.
Hi @Anonymous
I use your to table and build a measure to achieve your goal.
Build a silcer by Last working day column in Date Table, then build a measure.
Measure =
VAR _selectedcolumn =
SELECTEDVALUE ( Table2[Last working day] )
VAR _Datediff =
DATEDIFF ( MAX ( 'Table1'[data_Date] ), _selectedcolumn, MONTH )
RETURN
IF (
_Datediff >= 0
&& _Datediff < 4,
CALCULATE ( SUM ( 'Table1'[Value] ) ),
BLANK ()
)
Build a matrix visual as below:
Result:
Select 2020/07/31
Select 2020/05/29
You can download the pbix file from this link: Date table in a Power BI report
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your problem or share me with your pbix file from your Onedrive for Business.
Best Regards,
Rico Zhou
Hi @Anonymous
I use your to table and build a measure to achieve your goal.
Build a silcer by Last working day column in Date Table, then build a measure.
Measure =
VAR _selectedcolumn =
SELECTEDVALUE ( Table2[Last working day] )
VAR _Datediff =
DATEDIFF ( MAX ( 'Table1'[data_Date] ), _selectedcolumn, MONTH )
RETURN
IF (
_Datediff >= 0
&& _Datediff < 4,
CALCULATE ( SUM ( 'Table1'[Value] ) ),
BLANK ()
)
Build a matrix visual as below:
Result:
Select 2020/07/31
Select 2020/05/29
You can download the pbix file from this link: Date table in a Power BI report
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , if select 1 date or set of date but want more data then that refer
https://www.youtube.com/watch?v=duMSovyosXE
if you simply want rolling you can use with date table
Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-3,MONTH))
Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],max(Sales[Sales Date]),-3,MONTH))
Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],startofmonth(Sales[Sales Date]),-3,MONTH))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184
Appreciate your Kudos.
User | Count |
---|---|
140 | |
113 | |
104 | |
76 | |
63 |
User | Count |
---|---|
135 | |
126 | |
110 | |
70 | |
61 |