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
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




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
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.