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 Team !
I'm Struggling with the select period date values for LAST YEAR sales ,
For select period Current Year Sale for DAX is as follows please suggest a DAX for Last YEAR considering followin Current Year DAX.
Solved! Go to Solution.
Hi @Anonymous ,
If you want to calcualte the total sales for previous period of selected period, you could create a flag measure:
Flag =
var _min=DATE(YEAR(MIN('Dates'[Date]))-1,MONTH(MIN('Dates'[Date])),DAY(MIN('Dates'[Date])))
var _max=DATE(YEAR(MAX('Dates'[Date]))-1,MONTH(MAX('Dates'[Date])),DAY(MAX('Dates'[Date])))
return IF( MAX('Sale Calculation'[Date]) >=_min && MAX('Sale Calculation'[Date])<=_max,1,0)
And apply it to visual-filter pane, set as "is 1":
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
If you want to calcualte the total sales for previous period of selected period, you could create a flag measure:
Flag =
var _min=DATE(YEAR(MIN('Dates'[Date]))-1,MONTH(MIN('Dates'[Date])),DAY(MIN('Dates'[Date])))
var _max=DATE(YEAR(MAX('Dates'[Date]))-1,MONTH(MAX('Dates'[Date])),DAY(MAX('Dates'[Date])))
return IF( MAX('Sale Calculation'[Date]) >=_min && MAX('Sale Calculation'[Date])<=_max,1,0)
And apply it to visual-filter pane, set as "is 1":
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
How about an all selected on your slicer values. Extract min and max date out of that filter context and then reduce both dates by one year and use this in a calculate function?
Hi Daniel,
Actually Not getting can you please form a DAX as per your knowlegde here and will try it on my measures .
Even i'm New to Power BI.
Hope you getting me.
Hi @Anonymous ,
cannot comment on your formula, but did you try use
DATESYTD & SAMEPERIODLASTYEAR
CALCULATE('Sale Calculation'[Total Sales], <-Measure or column? If column might need to put it into sum()
DATESYTD(
SAMEPERIODLASTYEAR(Dates[Date])
)
)
YES but using this DAX i'm just fecthing last year whole sales total