cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
skashifz
Frequent Visitor

Slicer selects latest date, need to show Sales for last X days

Hello,

I am new to Power BI. I have developed a Dashboard, which is based on FACT table, which have ratings us and of 4 Competitors for every date, and table also contains Week To Date ratings (Week starts Sunday). I have 1 Date Slicer in which i select 1 Date. There are 2 Stacked Bar Graphs, 1 shows Day ratings, other shows Week To Date ratings. Now i need to add another visual (Line Chart) to same dashboard to show last 30 day's ratings (ratings of each day individually). How can I achieve, because it is showing ratings of only the day selected in Slicer ofcourse. Any help of info or reference to older blog about this situation will be highly appreciated.

 

Thanks in advance

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@skashifz you need to add an explicit measure for sales amount that honors this disconnected table selection and use that measure in the above visual

 

Sum Sales Amount = 
CALCULATE ( 
    SUM ( FactInternetSales[SalesAmount] ), 
    TREATAS ( VALUES ( 'Dim Date Slicer'[FullDateAlternateKey] ), DimDate[FullDateAlternateKey] ) 
)

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 

 






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

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





View solution in original post

7 REPLIES 7
parry2k
Super User
Super User

@skashifz you need to add an explicit measure for sales amount that honors this disconnected table selection and use that measure in the above visual

 

Sum Sales Amount = 
CALCULATE ( 
    SUM ( FactInternetSales[SalesAmount] ), 
    TREATAS ( VALUES ( 'Dim Date Slicer'[FullDateAlternateKey] ), DimDate[FullDateAlternateKey] ) 
)

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 

 






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

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





parry2k
Super User
Super User

@skashifz solution attached.

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.






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

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





skashifz
Frequent Visitor

@parry2k Thank you very much for the effort. The problem is, that top chart is now NOT showing value for the date selected by Slicer. It is showing sum of all dates (or upto selected date).

 

AdventureWorksDW1-LineChart2.JPG

Greg_Deckler
Super User
Super User

@skashifz No sample data so can't be specific but should be something along the lines of:

Measure =
  VAR __Date = MAX('Table'[Date])
  VAR __30DaysAgo = __Date - 30
RETURN
  AVERAGEX(FILTER(ALL('Table'),[Date]>=__Date && [Date]<=__30DaysAgo),[Rating])

@ me in replies or I'll lose your thread!!!
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

@Greg_Deckler will this give average of all previous days, or will it give value for each day seperately so i can graph trend for all these previous days ? May be I should work to get a small sample pbix to show this ?

@skashifz 

pls provide the sample data and expected output.





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

Proud to be a Super User!




@Greg_Deckler , @ryan_mayu  I have attached dropbox link to the pbix file based on AdventureWorksDW. The Line Chart is showing one date on the axis, I want to show last 30 days on x axis and Sales values for those dates in this line chart.

Hope I cleared myself, and Thank you so much for the help. Really appreciate it.

AdventureWorksDW1-LineChart.JPG

https://www.dropbox.com/s/9wmxewsfn5p2bzl/AdventureWorksDW1.pbix?dl=0

 

Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Show episode 9

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 26

New Date - Check it Out!

Mark your calendars and join us on Thursday, October 6 at 11a PDT for a great session with Ted Pattison!

Top Solution Authors