Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
YunJ
Post Prodigy
Post Prodigy

How to make a bar chart based to time filter?

hi,

I'm wondering if I select filter 2020.04, can it show bar chart from 2020.01 to 2020.04?

 

微信图片_20200426182616.png微信图片_20200426182624.png

 

It would be great if you could provide a pbix sample file. Thanks a lot. Yun

1 ACCEPTED SOLUTION

Hi @YunJ ,

 

Sample .pbix  has been updated.

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
V-lianl-msft
Community Support
Community Support

Hi @YunJ ,

 

First you need to create an unrelated calendar table as a slicer.

Then create the following measure and apply it to the visual level filter.

Measure =
IF (
    YEAR ( MAX ( 'Table'[date] ) ) = SELECTEDVALUE ( 'Table 2'[year] )
        && MONTH ( MAX ( 'Table'[date] ) ) <= SELECTEDVALUE ( 'Table 2'[month] )
        && MONTH ( MAX ( 'Table'[date] ) ) >= 1,
    1
)

test_0427.PNG

Sample .pbix

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, could you please save to 2019.11 version or before?

 

Thanks

Yun

 

Hi @YunJ ,

 

Sample .pbix  has been updated.

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

nandukrishnavs
Community Champion
Community Champion

@YunJ 

 

Sales

DateSales
01 January 2020350
01 February 2020120
01 March 2020456
01 April 2020246
01 May 2020100
01 June 2020400
01 July 2020500
01 August 2020120
01 September 2020205
01 October 2020456
01 November 2020246
01 December 2020100

 

DateTable

Date
01 January 2020
01 February 2020
01 March 2020
01 April 2020
01 May 2020
01 June 2020
01 July 2020
01 August 2020
01 September 2020
01 October 2020
01 November 2020
01 December 2020

 

Do not create any relationship.

 

create a DAX measure

 

Date Filter = 
var d=MONTH(SELECTEDVALUE(DateTable[Date]))
var c=MONTH(SELECTEDVALUE(Sales[Date]))
var result= IF(d<=c,0,1)
return result

 

Create slicer from DateTable

slicer.JPG

 

create a bar chart using the Sales Table.

Then drag DateFilter measure into the visual level filter. Value is 1

out.JPG

 

Try this.

 



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

Thanks a lot!

Could you please send me the pbix file?

Also, why we cannot set the relationship? Because sometimes not every month has value, at this time I also need its month on the axis (although there is no value).

Thanks!

Yun

Sorry I didn't save the file. Please follow the above steps. I'm sure you can replicate the same.

If you enable the relationship between the above mentioned tables, automatically filter the bar chart based on slicer.

The idea here is, you have to write the logic in the DateFilter measure. I have provided you one example. Based on your real scenario, you can tweak its logic.

Regards,
Nandu Krishna

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors