cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
H_insight
Helper III
Helper III

Showing All Sales from a Selected Date in a Stacked Column Chart

 

Hi All,

 

Attached is a sample file that contains Sales, product and dates tables. I have a stacked column chart which is showing total sales by-products for each month (See below)

 

HeshamK_0-1614930327350.png

I am trying to write a measure that will show all sales from the selected date (slicer). So when I choose Jun 20, the stacked chart will show data from Jan to Jun 20 only.

Any hints or help is much appreciated. 

 

Many thanks

Sample File Download 

1 ACCEPTED SOLUTION

@H_insight , then you need an independent table.

 

With filter from that independent date table

 

YTD=
var _Max = maxx(allselected(Newdate), NewDate[Date])
var _min= datediff(year(_Max), 1,1)
return
CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date] >=_min && 'Date'[Day of Year] <= _max) )

 

refer for independent table

https://www.youtube.com/watch?v=duMSovyosXE

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@H_insight , In case you have date, Create YTD measure

example


YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))

 

use date table

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

Hi @amitchandak 

 

The above Dax will give me the YTD as a single column, but I want to show the monthly sales stacked in a column for each product. So when I select Jun 20, the stacked column will show sales form Jan-Jun 20.

@H_insight , then you need an independent table.

 

With filter from that independent date table

 

YTD=
var _Max = maxx(allselected(Newdate), NewDate[Date])
var _min= datediff(year(_Max), 1,1)
return
CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date] >=_min && 'Date'[Day of Year] <= _max) )

 

refer for independent table

https://www.youtube.com/watch?v=duMSovyosXE

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

Thanks for your help @amitchandak 

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Dev Camp Session 22 768x460.jpg

Check it out!

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