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
Yal
Regular Visitor

Selecting two dates to filter a graph

Hi all, 

 

I'm trying to create a measure, but I can not figurate out how.

I have a table where I have a start and end date and some other information, and I have a graph that shows all the temperatures for the year, I would like when a date is choosen the graph shows only the information from the start to end time. 

The relation between the tables is ID.

 

 

Date StartDate EndNameTotal Time (h)ID
01/01/2005 14.2501/01/2005 15.25AAA11
02/01/2005 14.2502/01/2005 15.25BBB11

 

DateTemperatureID
01/01/2005 13.25   25,001
01/01/2005 13.30   25,101
01/01/2005 14.00   25,021
01/01/2005 14.15   24,91
01/01/2005 14.30   25,021
01/01/2005 14.45   25,011

Annotation 2020-07-23 103837.png

 

Thanks!

 

 

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Yal ,

 

You need to add the following measures:

 

 

Temperature Calculation = 
VAR Start_Value =
    MIN ( Periods[Date Start] )
VAR End_Value =
    MAX ( Periods[Date End] )
RETURN
    SUMX (
        FILTER (
            SUMMARIZE ( 'Details'; Details[Date]; Details[Temperature] );
            'Details'[Date] >= Start_Value
                && 'Details'[Date] <= End_Value
        );
        'Details'[Temperature]
    )

 

 

Now setup your chart with the date from the Details table and this measure and add a slicer based on the periods table.

 

As you can see in the attach file everything works properly, just for the sake of comparision I have made the following changes to your data:

  • Added two periods 000 and ZZZ to have dates period before and after you two periods so you could see that the bottom chart is the same
  • Added a line in the 1/1/2020 at 5:45 PM (outside any of the periods) so you could see that the value in the middle was also not choosen

 

Please be aware that this solution will give you all the values between the periods so if you select 2 non consecutive periods all of the periods in between will also be choosen in the visualization.

 

Check PBIX file attach.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @Yal ,

 

You need to add the following measures:

 

 

Temperature Calculation = 
VAR Start_Value =
    MIN ( Periods[Date Start] )
VAR End_Value =
    MAX ( Periods[Date End] )
RETURN
    SUMX (
        FILTER (
            SUMMARIZE ( 'Details'; Details[Date]; Details[Temperature] );
            'Details'[Date] >= Start_Value
                && 'Details'[Date] <= End_Value
        );
        'Details'[Temperature]
    )

 

 

Now setup your chart with the date from the Details table and this measure and add a slicer based on the periods table.

 

As you can see in the attach file everything works properly, just for the sake of comparision I have made the following changes to your data:

  • Added two periods 000 and ZZZ to have dates period before and after you two periods so you could see that the bottom chart is the same
  • Added a line in the 1/1/2020 at 5:45 PM (outside any of the periods) so you could see that the value in the middle was also not choosen

 

Please be aware that this solution will give you all the values between the periods so if you select 2 non consecutive periods all of the periods in between will also be choosen in the visualization.

 

Check PBIX file attach.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Yal
Regular Visitor

Thank you Miguel, It works perfectly! Bests regards

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.