Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello, i want to show sales of cars based on dateslicer. But for one brand i want to show also the last 3 months.
My table contains three columns - For example:
Type | Brand | Date |
Car | BMW | 01-01-2020 |
Car | Mercedes | 02-03-2020 |
Now i would like to count all the types based on the brand and show it in a barchart. But for BMW they should also display the last 3 months based on the date slicer. When i choose 01/01/2020 - 31/12/2021, then it should display also data for BMW from 01/10/2019. Here is an example what i would like to achieve:
Thanks in advance
Solved! Go to Solution.
Hi @Krexx
I build a table like yours to have a test.
Firstly, you need to build a calendar table.
Date = CALENDARAUTO()
Use calendar table to build a Slicer.
Then build a measure to achieve your goal.
Measure =
VAR _MinDate =
MINX ( 'Date', 'Date'[Date] )
VAR _MaxDate =
MAXX ( 'Date', 'Date'[Date] )
VAR _Last3Month =
EOMONTH ( _MinDate, -4 ) + 1
RETURN
SUMX (
'Table',
IF (
MAX ( 'Table'[Brand] ) = "BMW"
&& MAX ( 'Table'[Date] ) >= _Last3Month
&& MAX ( 'Table'[Date] ) <= _MaxDate,
1,
IF (
MAX ( 'Table'[Brand] ) = "Mercedes"
&& MAX ( 'Table'[Date] ) >= _MinDate
&& MAX ( 'Table'[Date] ) <= _MaxDate,
1,
0
)
)
)
Build a Clustered column chart and the result is as below.
Default:
Change the slicer between 2020/01/01 and 2020/12/31.
You can download the pbix file from this link: Filter table based on date slicer, but one fieldname need to show last 3 months too
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 @Krexx
I build a table like yours to have a test.
Firstly, you need to build a calendar table.
Date = CALENDARAUTO()
Use calendar table to build a Slicer.
Then build a measure to achieve your goal.
Measure =
VAR _MinDate =
MINX ( 'Date', 'Date'[Date] )
VAR _MaxDate =
MAXX ( 'Date', 'Date'[Date] )
VAR _Last3Month =
EOMONTH ( _MinDate, -4 ) + 1
RETURN
SUMX (
'Table',
IF (
MAX ( 'Table'[Brand] ) = "BMW"
&& MAX ( 'Table'[Date] ) >= _Last3Month
&& MAX ( 'Table'[Date] ) <= _MaxDate,
1,
IF (
MAX ( 'Table'[Brand] ) = "Mercedes"
&& MAX ( 'Table'[Date] ) >= _MinDate
&& MAX ( 'Table'[Date] ) <= _MaxDate,
1,
0
)
)
)
Build a Clustered column chart and the result is as below.
Default:
Change the slicer between 2020/01/01 and 2020/12/31.
You can download the pbix file from this link: Filter table based on date slicer, but one fieldname need to show last 3 months too
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.
@Krexx - Sorry, having trouble following, can you post sample data as text and expected output?
Maybe Complex Selector? https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Complex-Selector/m-p/1116633#M534
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
@Krexx , not very clear
You can use rolling 3
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 ],MAX('Date'[Date ]),-3,MONTH))
or this approach
https://www.youtube.com/watch?v=duMSovyosXE
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
123 | |
78 | |
48 | |
38 | |
37 |
User | Count |
---|---|
196 | |
80 | |
70 | |
51 | |
42 |