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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
JanD
Frequent Visitor

Dynamic bar chart per month depending on slicer selection

Hi everyone, 

 

I am looking for an advise here. I have actual data currently up to March 2024 and Forecast per every month available. 

I need to visualize data on a bar chart per month, in a way that the chart will change based on single select slicer (month) on that page. 

Meaning if I select February on the slicer, the bar chart will show January and February actual data, but Forecast for the rest of the monhts. 

If I select June, the bar chart will show January, February and March actual data, but the rest as there is no actual available should be Forecast. 

 

Thank you for your help in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @JanD 

As you mentioned, you have actual data and forecast data, and I created a sample data as follows:

vjianpengmsft_0-1712900370739.png

First, I created a date table based on this table, as shown in the following image:

vjianpengmsft_1-1712900426363.png

Use the Date column of this table as the slicer option:

vjianpengmsft_2-1712900511115.png

Use the following DAX expressions to dynamically calculate the actual data before the slicer selected month:

Y axis =
VAR _seletmonth =
    CALCULATE (
        MAX ( 'Table 2'[Date] ),
        SELECTCOLUMNS ( 'Table 2', 'Table 2'[Date] )
    )
RETURN
    IF (
        MAX ( 'Table'[Dates] ) <= _seletmonth,
        CALCULATE ( SUM ( 'Table'[Actual data] ), 'Table'[Dates] <= _seletmonth ),
        CALCULATE ( SUM ( 'Table'[Forecast data] ), 'Table'[Dates] >= _seletmonth )
    )

The stacked column chart visual is set as follows:

vjianpengmsft_3-1712900723952.png

When I select January, January corresponds to the actual data, and February and beyond are the forecast data.

vjianpengmsft_4-1712900748685.png

When I select February, January-February is the actual data, and the following months are the forecast data:

vjianpengmsft_5-1712900883934.png

I've provided the PBIX file used this time below.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

1 REPLY 1
Anonymous
Not applicable

Hi, @JanD 

As you mentioned, you have actual data and forecast data, and I created a sample data as follows:

vjianpengmsft_0-1712900370739.png

First, I created a date table based on this table, as shown in the following image:

vjianpengmsft_1-1712900426363.png

Use the Date column of this table as the slicer option:

vjianpengmsft_2-1712900511115.png

Use the following DAX expressions to dynamically calculate the actual data before the slicer selected month:

Y axis =
VAR _seletmonth =
    CALCULATE (
        MAX ( 'Table 2'[Date] ),
        SELECTCOLUMNS ( 'Table 2', 'Table 2'[Date] )
    )
RETURN
    IF (
        MAX ( 'Table'[Dates] ) <= _seletmonth,
        CALCULATE ( SUM ( 'Table'[Actual data] ), 'Table'[Dates] <= _seletmonth ),
        CALCULATE ( SUM ( 'Table'[Forecast data] ), 'Table'[Dates] >= _seletmonth )
    )

The stacked column chart visual is set as follows:

vjianpengmsft_3-1712900723952.png

When I select January, January corresponds to the actual data, and February and beyond are the forecast data.

vjianpengmsft_4-1712900748685.png

When I select February, January-February is the actual data, and the following months are the forecast data:

vjianpengmsft_5-1712900883934.png

I've provided the PBIX file used this time below.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.