The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hi all,
i am having data from Jan 2018 to May 2021
I am currently showing KPIs for a selected range of data which i am using it in a date slicer (between).
i am able to get the selected min date and max date from the dax
var _mindate=min(calander[date])
var _maxdate=max(calander[date])
and i am showing the range for current selected period by
Now here i am facing issue showing the date range.
When i select Sep 18 to Aug 19
Current Year is
For the previous year range label , i have only data from jan 18 but
when i use this measure
Hi @Anonymous
Try this measure:
Previousperioddaterange =
var _mindate=CALCULATE([Mindate],SAMEPERIODLASTYEAR(Calander[Date]))
var _maxdate=CALCULATE([Maxdate],SAMEPERIODLASTYEAR(Calander[Date]))
var PreMindt=if(_mindate>=[Mindate],FORMAT(_mindate,"mmm YYYY"),blank())
var PreMaxdt=if(isblank(PreMindt),blank(),FORMAT(_maxdate,"mmm YYYY"))
return
COMBINEVALUES("-",PreMindt,PreMaxdt)
You can find the previous period regardless of available date, with this code:
Previousperioddaterange =
Var _Min = [Mindate]
Var _Max = [Maxdate]
var _mindate=date(year(_Min)-1,month(_Min),day(_Min))
var _maxdate=date(year(_Max)-1,month(_Max),day(_Max))
var PreMindt=FORMAT(_mindate,"mmm YYYY")
var PreMaxdt=FORMAT(_maxdate,"mmm YYYY")
return
COMBINEVALUES("-",PreMindt,PreMaxdt)
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Hi @VahidDM
I have tried first one its not suitable for my problem, and second one is working fine but in my data i have range from Jan 2018 to May 2021. So if i select a current date range of July 2018 - Dec 2018 it should show "No data" but its showing July 2017 - Dec 2017 for which i dont have a data.
User | Count |
---|---|
14 | |
11 | |
8 | |
6 | |
5 |
User | Count |
---|---|
28 | |
19 | |
13 | |
8 | |
5 |