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
Highlighted
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
Highlighted
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 IV
Super User IV

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
May 2020 Community Highlights

May 2020 Community Highlights

It’s time for another PBI Community recap!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Top Solution Authors