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.
Hi,
I have a fact table that I want to calculate the total sales for 2018, 2019, 2020, 2021 and 2022.
I am using a bar chart to compare the selected year total sales vs total sales last year.
I am using the two DAX functions below to calculate both measures and I got the result as expected.
*****************************************************
Total Sales =
SUMX( Fsales ,
fSales[REV_TRANSACTION_AMOUNT]
)
Total Sales LY =
CALCULATE(
[Total Sales],
SAMEPERIODLASTYEAR( dCalendar[Date] ))
*****************************************************
The problem is:
When I am visualizing the bar chart to the current year 2022, I am getting information on the columns August, September, October, November, and December from the last year only, which is obvious as I still don't have this information about my current year.
Does anyone know how I could work around it and not show information about TOTAL SALES LY to the future months of my current year?
- When selecting current 2022 I don't want to show Sep, Oct, Nov, and Dec
- When selecting years before current year (2022) it should shows like this
Solved! Go to Solution.
@murillocosta , Try measures like examples
SAMEPERIODLASTYEAR QTY forced=
var _max1 = COALESCE(maxx(allselected('Order'),'order'[Date]),today())
var _max2 = if(_max1 >today(),today(), _max1)
var _max = format(_max2,"MMDD")
return
calculate(Sum('order'[Qty]),SAMEPERIODLASTYEAR('Date'[Date]),filter('Date', format('Date'[Date],"MMDD")<=_max))
OR
SAMEPERIODLASTYEAR QTY forced=
var _max1 = COALESCE(maxx(allselected('Order'),'order'[Date]),today())
var _max2 = if(_max1 >today(),today(), _max1)
var _max = format(_max2,"MMDD")
return
if( format(max('Date'[Date]),"MMDD")<=_max, calculate(Sum('order'[Qty]),SAMEPERIODLASTYEAR('Date'[Date])), blank())
@murillocosta , Try measures like examples
SAMEPERIODLASTYEAR QTY forced=
var _max1 = COALESCE(maxx(allselected('Order'),'order'[Date]),today())
var _max2 = if(_max1 >today(),today(), _max1)
var _max = format(_max2,"MMDD")
return
calculate(Sum('order'[Qty]),SAMEPERIODLASTYEAR('Date'[Date]),filter('Date', format('Date'[Date],"MMDD")<=_max))
OR
SAMEPERIODLASTYEAR QTY forced=
var _max1 = COALESCE(maxx(allselected('Order'),'order'[Date]),today())
var _max2 = if(_max1 >today(),today(), _max1)
var _max = format(_max2,"MMDD")
return
if( format(max('Date'[Date]),"MMDD")<=_max, calculate(Sum('order'[Qty]),SAMEPERIODLASTYEAR('Date'[Date])), blank())
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
24 | |
20 | |
15 | |
12 |
User | Count |
---|---|
55 | |
48 | |
43 | |
19 | |
18 |