Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi All
I need to create a bar chart where I have trailing 12 months bars along with counts of categories of top 3+1(other).
1. I have created a calendar table and another column for End of month to use that in slicer (Month,Year). [calendar Table]
2. Created a table for unique categories and then calculated the counts.
*****************************************
I tried this but I have one more challenge along this , need to apply two filters
1. Is trailing 12 months
2. If user selects Jan'22 in calendar end date then will get counts if start date <= user select date and end date >= user select date
Based on that I have created this measure but it's not working
@SK87
I don't fully understand your filter requirements. But in general you need to filter the DATESINPERIOD table. In the same file you can find a measure that filters the days in the pervious months based on the selected dates. For example if you select 15th of December 2021 then all the previous months will be filtered to show the data upto the 15th of each month. Not sure if that helps you.
There are two filter requirements:
1. Suppose if user select Dec'21 in slicer, then the data will filter out as described below:
In start date column data would be selected less than equal to user selection that is <=Dec'21 and in end date selection would be greater than equal to user selection >-Dec'21.
which I can get by below measure:
1. Many to one actie relationship Data[SELECT MONTH] - Calendartable[DATE]
2. Many to one Inactive relationship Calendartable[Date] - Previous persiod[selectmonth]
Previous period is copy of calendar table
Please try
=
VAR Smonth =
MAX ( 'calendartable'[StartofMonth] )
VAR Smonth1 =
MAX ( 'calendartable'[EO Month] )
RETURN
CALCULATE (
COUNT ( 'Data'[Categories] ),
'Data'[End Date] >= Smonth,
'Data'[Start Date] <= Smonth1,
CROSSFILTER ( Data[SELECT MONTH], Calendartable[DATE], NONE )
)
@tamerj1 Thanks for the solution.
But how trailing 12 months will function, in above measure related to trailing 12 months nothing is specifed.
Probably in this case a previous date table shall not be required. I'll look into it tomorrow.
Guys anyone who could help me in solving this problem, it would be great help.
Thanks in advance.
Hi @SK87
please try the method I proposed in in this post
https://community.powerbi.com/t5/Desktop/Display-data-for-previous-6-months/m-p/2719708#M949700