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
H_insight
Helper V
Helper V

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

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.

 

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

Thanks for your help @amitchandak 

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