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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Serrano
Frequent Visitor

3 charts showing next 3 weeks of data thru dropdown filter

Hello,

I need to make a page where a user selects a week in table SENSORD by means of the dropdown slicer. The page has 3 charts with X the dates in table SENSORD (including week number), and Y the values of a sensor.

Based on the selected week, I need to show in 1st chart the Y values of the selected week (which is easy). But in 2nd chart I want to show the values of the next week, and in the 3rd chart the one of the following week. All with one slicer (to make it user-friendly). Any idea how?

Thank you.

3 REPLIES 3
bhanu_gautam
Super User
Super User

@Serrano 

Ensure you have a date table that includes all the dates and their corresponding week numbers. This table will be used to create relationships and slicers.

 

Establish relationships between your date table and the SENSORD table based on the date field.

 

Create a measure for the selected week.
Create a measure for the next week.
Create a measure for the week after the next week.

 

DAX
SelectedWeekValues =
CALCULATE(
SUM(SENSORD[SensorValue]),
FILTER(
SENSORD,
SENSORD[WeekNumber] = SELECTEDVALUE(DateTable[WeekNumber])
)
)

NextWeekValues =
CALCULATE(
SUM(SENSORD[SensorValue]),
FILTER(
SENSORD,
SENSORD[WeekNumber] = SELECTEDVALUE(DateTable[WeekNumber]) + 1
)
)

FollowingWeekValues =
CALCULATE(
SUM(SENSORD[SensorValue]),
FILTER(
SENSORD,
SENSORD[WeekNumber] = SELECTEDVALUE(DateTable[WeekNumber]) + 2
)
)

 

Create three separate charts.
Assign the SelectedWeekValues measure to the first chart.
Assign the NextWeekValues measure to the second chart.
Assign the FollowingWeekValues measure to the third chart.

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






@bhanu_gautam 

 

Hi. Your solution works for the 1st chart, but not for the 2nd and 3rd.

I don't know if it is not working because SENSORD is already filter.

According to the command ISFILTERED, it shows negative.

Even without using SELECTEDVALUE:

SENSORD[WeekNumber] = 6

still not working for 2nd and 3rd.

 

Any idea why?

If the measures for the next week and the week after that are not working, it might be due to the filtering context. Ensure that the SENSORD table is not being filtered in a way that conflicts with the measures. You can also try using the ALL function to remove any existing filters on the SENSORD table:

 

NextWeekValues =
CALCULATE(
SUM(SENSORD[SensorValue]),
FILTER(
ALL(SENSORD),
SENSORD[WeekNumber] = SELECTEDVALUE(DateTable[WeekNumber]) + 1
)
)

 

FollowingWeekValues =
CALCULATE(
SUM(SENSORD[SensorValue]),
FILTER(
ALL(SENSORD),
SENSORD[WeekNumber] = SELECTEDVALUE(DateTable[WeekNumber]) + 2
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements