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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
lrnt12
Frequent Visitor

Creating Measure to switch between Daily, Weekly, Monthly, Yearly

Hello,

I have temperature values coming every 15 minutes (two columns - value and time). Is it possible to create a measure that calculates the average Hourly, Daily, Weekly, Monthly and somehow incorporated into a slicer that would control a line chart? 

 

I created separate columns for date time (Hour, Day, Week and Month), but I have troubles creating a measure that will calculate the average depending on the slider.

 

Any help/direction would be much appreciated.

 

Regards,

Laurent

1 ACCEPTED SOLUTION
Anonymous
Not applicable

So you would like to have the x-axis to change depending on the value chosen in the slicer? As far as I know a measure cannot be set on the axis.

 

One solution could be using bookmarks instead. Create the four charts for each time period above eachother and use buttons assigned with bookmarks to toggle between the charts.

 

 

 

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi Laurent,

 

Maybe something like this?

 

Avg Temp Dynamic = 
SWITCH(
TRUE();
SELECTEDVALUE('Calculation'[Calculation]) = "Hourly"; [Avg Temp Hourly];
SELECTEDVALUE('Calculation'[Calculation]) = "Daily"; [Avg Temp Daily];
SELECTEDVALUE('Calculation'[Calculation]) = "Weekly"; [Avg Temp Weekly]
)

In this case I created a table with the different alternatives to choose between the calculations. Then I've created the different measures seperately for each calculation and just referenced them in this dynamic measure.

 

Hope this helps!

PattemManohar
Community Champion
Community Champion

@lrnt12 Please try using SWITCH and SELECTEDVALUE funtions...

 

Sample data and expected output will be helpful to provide an accurate solution.





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

Hi Pattem~ I will be happy if you tell me how I can create this table with that table.  THank you so much.

 

timebuttons.PNG

 

data.PNG

Thanks for the reply.

 

My data looks like this. Value and Datetime field is what I pull from the source.

 

valuetime.JPG

 

The expected output should be a slicer that would control the line chart. When I select Daily, I should see the average value for each day. 

expected.JPG

 

Basically, instead of having to drill up and down on the line chart, I'd like to control this with a slicer.

 

I have tried using SWITCH and SELECTEDVALUE, but it doesn't seem to work. Or perhaps I haven't used it right.


Thanks,

Laurent

Anonymous
Not applicable

So you would like to have the x-axis to change depending on the value chosen in the slicer? As far as I know a measure cannot be set on the axis.

 

One solution could be using bookmarks instead. Create the four charts for each time period above eachother and use buttons assigned with bookmarks to toggle between the charts.

 

 

 

Anonymous
Not applicable

But I want to interact with the whole report . Then What I can do, for this case.?

@Anonymous ... thinking outside the box, huh? Can't belive I didn't even think about it. Thanks !!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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