The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
Need help on DAX , client requested to show last 4 years sales with current YTD.
Thanks,
Francis
Solved! Go to Solution.
Hi @Anonymous ,
Please mark the answer as solution if it works.
If not, please show some sample data and expected result to us.
Best Regards,
Jay
@Anonymous , I think you need the last 4 years + data till today
Try like
Last 4 year till date =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1*MONTH(_max) -48 )+1
return
CALCULATE([net] ,filter('Date', 'Date'[Date]>= _min && 'Date'[Date]<= _max))
or
Last 4 year till date =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1*MONTH(_max) -48 )+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))
User | Count |
---|---|
20 | |
8 | |
7 | |
7 | |
6 |
User | Count |
---|---|
28 | |
12 | |
12 | |
9 | |
8 |