Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Getting different data based on a Range column.

Hi All, I have some issue regarding getting different set of data by using date measure. 

 

ameng_0-1658807126325.png

This is the PBI file that i'm working on. 

Based on above figure, this is the range, and the data produced by that range but that's not aligned with what i should get. What i should get is  an output something like this

ameng_1-1658807126376.png

 

for example, on the "selectedDate" range slicer, i'm choosing 24 February 2018, the result for year 2017 should be in the selected date of 24 February 2017 and for year 2016, it should be in the selected of 24 February 2016. I'm not sure what measure should i change and how to proceed. The data for "no of orders by selected month" should be just the total count of those in Jan and Feb in every year only based on below table.

ameng_2-1658807126372.png

 


List of Measures used-

No of Orders by Selected Month =
VAR _selectedmonthselecteddate = [test]
RETURN CALCULATE([Order Count]'Calendar'[MonthNum] <= _selectedmonthselecteddate)
 
test = CALCULATE(MAX('Calendar'[MonthNum]), Filter('Calendar',[MonthNum] = Month(_Formulas[SelectedDate])))

 

SelectedDate =
Var _SelectedDate = Max('Calendar'[Date])
Return _SelectedDate

This is the PBI file that i'm working on. Hope you all have a nice day ahead, thank you!!

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a measure such as:

SelectedDate = 
Var _SelectedDate = CALCULATE( Max('Calendar'[Date]),ALLSELECTED('Calendar'))
Return CALCULATE(MAX('Calendar'[Date]),FILTER('Calendar',MONTH([Date])=MONTH(_SelectedDate)&&DAY([Date])=DAY(_SelectedDate)))
No of Orders by Selected Month = 
Var _SelectedDate = CALCULATE( Max('Calendar'[Date]),ALLSELECTED('Calendar'))
var _piryear= CALCULATE(  [Order Count],FILTER(ALL('Calendar'),YEAR([Date])=MAX('Calendar'[Year])&& MONTH([Date])<=MONTH(_SelectedDate)))
return IF(YEAR(MAX('Calendar'[Date]))=YEAR(_SelectedDate), CALCULATE(  [Order Count],FILTER(ALL('Calendar'),YEAR([Date])=MAX('Calendar'[Year])&& [Date]<=_SelectedDate)),_piryear)

the final show:

vyalanwumsft_0-1659080240980.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a measure such as:

SelectedDate = 
Var _SelectedDate = CALCULATE( Max('Calendar'[Date]),ALLSELECTED('Calendar'))
Return CALCULATE(MAX('Calendar'[Date]),FILTER('Calendar',MONTH([Date])=MONTH(_SelectedDate)&&DAY([Date])=DAY(_SelectedDate)))
No of Orders by Selected Month = 
Var _SelectedDate = CALCULATE( Max('Calendar'[Date]),ALLSELECTED('Calendar'))
var _piryear= CALCULATE(  [Order Count],FILTER(ALL('Calendar'),YEAR([Date])=MAX('Calendar'[Year])&& MONTH([Date])<=MONTH(_SelectedDate)))
return IF(YEAR(MAX('Calendar'[Date]))=YEAR(_SelectedDate), CALCULATE(  [Order Count],FILTER(ALL('Calendar'),YEAR([Date])=MAX('Calendar'[Year])&& [Date]<=_SelectedDate)),_piryear)

the final show:

vyalanwumsft_0-1659080240980.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , For of if you take a joined date table data will merge in one single date

So use an independent date in the slicer

 

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = format(maxx(allselected(Date1),Date1[Date]), "mmdd")
return
calculate( sum(Table[Value]), filter('Date',format( 'Date'[Date] "mmdd") =_max))

 

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak , thank you for replying, i really do appreaciate it.
Just had a simple question, what does it mean by independent date table by your definition? From my POV, i did used an independent date table which is "Calendar" table. Do correct me if i'm wrong, thank you!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.