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
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.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


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.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


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.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


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 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!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@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
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.

Top Solution Authors