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
Anonymous
Not applicable

Show data by different time intervals based on a slicer

Hi all,

 

In my report I have a graph with datetime on the x-axis. The parameter values come in by the minute, so I'm using Direct Query to show the latest data.

 

Now I want to be able to switch between showing (aggregated) data per 1min, 5mins, 15mins and 60mins, based on a slicer in the report.

Can anybody tell me how to do this, especially since DAX functionality is limited in Direct Query?

 

Thanks, br.

 

Olaf

5 REPLIES 5
Anonymous
Not applicable

In the end we solved this by adapting the underlying datatable:

- Added a column "interval" with four values, one for each required interval (1, 5, 15, 60)

- Every time corresponding to a 5, 15 or 60 minute interval, we added a row with the calculated averag over taht interval, for each parameter

Now we simply used the "interval column in a slicer.

 

Not the most "clean" solution, but it works for our use case.

 

Next case though we will try Stachu's code.

Stachu
Community Champion
Community Champion

SWITCH should be a possibility, but maybe there is more performant solution

can you share the anonymised sample of your data? if you already have the measures showing the individual aggregates, can you share the syntax?



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

The data looks something like this, only with around 40 parameters and a new row being added every minute.

slicer_test_data.PNG

 

The processing is done before Power BI, so the aggregation would be done there.

Hi @Anonymous,

What is your desired result?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

try this code - I assume you already have a slicer that has numeric values 1,5,15,60

Measure =
VAR Minutes =
    MAX ( Slicer[SlicerValue] )
RETURN
    CALCULATE (
        SUM ( Table[dT] ),
        Table[DateTime]
            >= TODAY () + NOW () - Minutes / ( 24 * 60 )
    )


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

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.