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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
prateekraina
Memorable Member
Memorable Member

Running Line chart based on Time slicer

Hello All,

 

I need to create a line chart for below data with Time on Axis and NoOfPeople on Values:

Camera	NoOfPeople	Time      ID
Cam 1	10	        10:10 AM   1
Cam 1	3	        10:15 AM   2
Cam 1	44	        10:20 AM   3
Cam 1	2	        10:25 AM   4
Cam 1	3	        10:30 AM   5
Cam 1	55	        10:35 AM   6
Cam 1	4	        10:40 AM   7
Cam 1	44	        10:45 AM   8
Cam 1	33	        10:50 AM   9

Problem Statement:
I have a line chart and a slicer in which Time is selected

If i choose 10:25 AM in my Time Slicer i should only see data plotted in Line Chart till 10:25 AM i.e. Last 5 entries are not plotted.
Similarily if choose 10:15 AM in my Time Slicer i should only see data plotted for 1st two entries and so on.

Can anybody suggest any trick for doing this?

 

Prateek Raina

 

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

Hi @prateekraina,

 

Based on my test, you should be able to follow steps below to get your expected result. 

 

1. Add a new table with all possible Time value, and make sure there is no relationship between the two tables.

 

re1.PNG

 

2. Use the formula below to create a new measure.

Measure =
CALCULATE (
    SUM ( Table1[NoOfPeople] ),
    FILTER ( Table1, Table1[Time] <= MAX ( Table2[Time] ) )
)

3. Then you should be able to show the Time column from your original table as Axis, and the measure as Value on Line Chart to get your expected result.

 

r1.PNG

Here is the sample pbix file for your reference. Smiley Happy

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Employee
Employee

Hi @prateekraina,

 

Based on my test, you should be able to follow steps below to get your expected result. 

 

1. Add a new table with all possible Time value, and make sure there is no relationship between the two tables.

 

re1.PNG

 

2. Use the formula below to create a new measure.

Measure =
CALCULATE (
    SUM ( Table1[NoOfPeople] ),
    FILTER ( Table1, Table1[Time] <= MAX ( Table2[Time] ) )
)

3. Then you should be able to show the Time column from your original table as Axis, and the measure as Value on Line Chart to get your expected result.

 

r1.PNG

Here is the sample pbix file for your reference. Smiley Happy

 

Regards

Thanks a lot for this @v-ljerr-msft.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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