cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Show data on line chart based on Period

Hi all,

 

I have a table contain Time  column (drill down by hour) and count column.

1.png

 
 

The data I try to show in line chart have a slicer called period (Hourly, Daily, Monthly, Weekly, Yearly)

 

Annotation 2020-02-27 135536.png

 

Can I choose the value on Period and the chart will reflect the period?

Any help is appreciated.

 

Thank you.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: Show data on line chart based on Period

Hi @Thai_Nguyen96

 

You can create a measure below, then drag this measure to the line chart: 

Measure = 
var y= CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date])))) 
var q= CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&QUARTER('Table'[Range Date])=QUARTER(MAX('Table'[Range Date]))))
var m=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&MONTH('Table'[Range Date])=MONTH(MAX('Table'[Range Date]))))
var w=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&WEEKNUM('Table'[Range Date])=WEEKNUM(MAX('Table'[Range Date]))))
var h=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&MONTH('Table'[Range Date])=MONTH(MAX('Table'[Range Date]))&& DAY('Table'[Range Date])=DAY(MAX('Table'[Range Date]))))
var d=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&MONTH('Table'[Range Date])=MONTH(MAX('Table'[Range Date]))&& DAY('Table'[Range Date])=DAY(MAX('Table'[Range Date]))&&HOUR('Table'[Range Date])=HOUR(MAX('Table'[Range Date]))))
return SWITCH(SELECTEDVALUE('Table (2)'[Period]),"Monthly",m,"Weekly",w,"Yearly",y,"Hourly",h,"Quarterly",q,"Daily",d)

 

q7.PNG

 

Best Regards,
Qiuyun Yu

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

View solution in original post

2 REPLIES 2
Community Support
Community Support

Re: Show data on line chart based on Period

Hi @Thai_Nguyen96

 

You can create a measure below, then drag this measure to the line chart: 

Measure = 
var y= CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date])))) 
var q= CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&QUARTER('Table'[Range Date])=QUARTER(MAX('Table'[Range Date]))))
var m=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&MONTH('Table'[Range Date])=MONTH(MAX('Table'[Range Date]))))
var w=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&WEEKNUM('Table'[Range Date])=WEEKNUM(MAX('Table'[Range Date]))))
var h=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&MONTH('Table'[Range Date])=MONTH(MAX('Table'[Range Date]))&& DAY('Table'[Range Date])=DAY(MAX('Table'[Range Date]))))
var d=CALCULATE(SUM('Table'[Count]),FILTER(ALL('Table'),YEAR('Table'[Range Date])=YEAR(MAX('Table'[Range Date]))&&MONTH('Table'[Range Date])=MONTH(MAX('Table'[Range Date]))&& DAY('Table'[Range Date])=DAY(MAX('Table'[Range Date]))&&HOUR('Table'[Range Date])=HOUR(MAX('Table'[Range Date]))))
return SWITCH(SELECTEDVALUE('Table (2)'[Period]),"Monthly",m,"Weekly",w,"Yearly",y,"Hourly",h,"Quarterly",q,"Daily",d)

 

q7.PNG

 

Best Regards,
Qiuyun Yu

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

View solution in original post

Highlighted
Super User IX
Super User IX

Re: Show data on line chart based on Period

Refer, if this can Help:

https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/50...



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
Meet the 2020 Season 2 Power BI Super Users!

Meet the 2020 Season 2 Power BI Super Users!

Find out who's part of the program this season, and welcome the new Super Users.

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Featured Data Story of The Month

Featured Data Story of The Month

All Data Stories Gallery contributions are reviewed for each month. We select a contribution and feature the community member the following month.

Power BI Dev Camp - Developing with .NET Core

Power BI Dev Camp - Developing with .NET Core

Learn how to develop custom web applications for Power BI using .NET Core 3.1 and .NET 5.

Top Solution Authors
Top Kudoed Authors