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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
hruv01
Frequent Visitor

Filtering the months in a line chart to display cumulative values up to the selected month

Hello, I'm having trouble coming up with the following task. I have a calendar table created in Power BI, and it is connected to another two tables, the first contains the number of working days in each month and the second is a fact table. I need to create a line chart, where the months' names are displayed on the x-axis and the values are calculated by dividing the number of items from the fact table by the number of working days from this table. However, I also want to enable a filter on the page based on the months, so that when the user selects March, for example, the cumulative values up to that chosen month will be displayed, resulting in the graph showing January, February, and March. How can I have connected tables and simultaneously filter cumulative values by month without filtering only the selected one?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @hruv01 ,

I created some data:

Month_Worknumber:

vyangliumsft_0-1686106387809.png

Items:

vyangliumsft_1-1686106387810.png

Relationships in tables:

vyangliumsft_2-1686106419754.png

Here are the steps you can follow:

1. Create measure.

Value =
var _items=
SUMX(
    FILTER(ALLSELECTED('items'),
    YEAR('items'[Date])=YEAR(MAX('items'[Date]))&&
    MONTH('items'[Date])=MONTH(MAX('items'[Date]))),[Projectnumber])
var _work=
SUMX(
    FILTER(ALLSELECTED('Month_Worknumber'),
    YEAR('Month_Worknumber'[Date])=YEAR(MAX('Month_Worknumber'[Date]))&&
    MONTH('Month_Worknumber'[Date])=MONTH(MAX('Month_Worknumber'[Date]))),[Worknumber])
return
_items / _work
Flag =
var _year=SELECTEDVALUE('calendar table'[Year])
var _month=SELECTEDVALUE('calendar table'[Month])
return
IF(
    YEAR(MAX('Month_Worknumber'[Date]))=_year &&MONTH(MAX('Month_Worknumber'[Date]))<=_month,1,0)
Measure =
SUMX(
    FILTER(ALLSELECTED(Month_Worknumber),
    YEAR('Month_Worknumber'[Date])=YEAR(MAX('Month_Worknumber'[Date]))&&
    MONTH('Month_Worknumber'[Date])<=MONTH(MAX('Month_Worknumber'[Date]))),[Value])

2. Result:

vyangliumsft_3-1686106431368.png

 

Best Regards,

Liu Yang

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

2 REPLIES 2
Anonymous
Not applicable

Hi  @hruv01 ,

I created some data:

Month_Worknumber:

vyangliumsft_0-1686106387809.png

Items:

vyangliumsft_1-1686106387810.png

Relationships in tables:

vyangliumsft_2-1686106419754.png

Here are the steps you can follow:

1. Create measure.

Value =
var _items=
SUMX(
    FILTER(ALLSELECTED('items'),
    YEAR('items'[Date])=YEAR(MAX('items'[Date]))&&
    MONTH('items'[Date])=MONTH(MAX('items'[Date]))),[Projectnumber])
var _work=
SUMX(
    FILTER(ALLSELECTED('Month_Worknumber'),
    YEAR('Month_Worknumber'[Date])=YEAR(MAX('Month_Worknumber'[Date]))&&
    MONTH('Month_Worknumber'[Date])=MONTH(MAX('Month_Worknumber'[Date]))),[Worknumber])
return
_items / _work
Flag =
var _year=SELECTEDVALUE('calendar table'[Year])
var _month=SELECTEDVALUE('calendar table'[Month])
return
IF(
    YEAR(MAX('Month_Worknumber'[Date]))=_year &&MONTH(MAX('Month_Worknumber'[Date]))<=_month,1,0)
Measure =
SUMX(
    FILTER(ALLSELECTED(Month_Worknumber),
    YEAR('Month_Worknumber'[Date])=YEAR(MAX('Month_Worknumber'[Date]))&&
    MONTH('Month_Worknumber'[Date])<=MONTH(MAX('Month_Worknumber'[Date]))),[Value])

2. Result:

vyangliumsft_3-1686106431368.png

 

Best Regards,

Liu Yang

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

lbendlin
Super User
Super User

the first contains the number of working days in each month 

Eliminate that table and add a "working day" flag in your calendar table.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.