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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
bobbysasi
Frequent Visitor

Get Previous Day (non consecutive) totals in a hierarchy

Hello All,

 

I have data as below

 

RegionCountryRecord DateNo. of Users
AsiaIndia10-Jan-22100
AsiaIndia

21-Feb-22

140
AsiaIndia18-Mar-22136
EuropeFrance03-Jan-22120
EuropeFrance17-Jan-22170
EuropeFrance19-Mar-22210
EuropeGermany13-Jan-22180
EuropeGermany17-Feb-22240
EuropeGermany29-Mar-22280
AsiaChina14-Jan-22201
AsiaChina21-Mar-22280
AsiaChina28-Mar-22290

 

 

I have a date filter and a line chart with Region on x-axis and No. of users on y-axis. When I select a date from filter, I want the chart to show region with user count as on selected date. That is, if I select 01-Apr-22, it should show consider below data

 

RegionCountryRecord DateNo. of Users
AsiaIndia18-Mar-22136
EuropeFrance19-Mar-22210
EuropeGermany29-Mar-22280
AsiaChina28-Mar-22290

 

and plot chart based on below data

 

RegionNo. of Users
Asia426
Europe490

 

Similarly, If I select 15-Feb-22, it should consider below data

 

RegionCountryRecord DateNo. of Users
AsiaIndia10-Jan-22100
EuropeFrance17-Jan-22170
EuropeGermany13-Jan-22180
AsiaChina14-Jan-22201

 

and plot chart using below data

RegionNo. of Users
Asia301
Europe350

 

If I have country on the x-axis, I am getting required output by below DAX

 

Users As On Selected Date =
var _selectedate = SELECTEDVALUE('DateFilter'[Date])
var _previousdate = CALCULATE(MAX('UserData'[Record Date]),'UserData'[Record Date]<=_selecteddate)
return CALCULATE(SUM('UserData'[No. of Users]),'UserData'[Record Date]=_previousdate)

 

Can any of you guide me on how to achieve this at Region level.

 

Thanks,

Bobby

2 REPLIES 2
bobbysasi
Frequent Visitor

It works. There is no error as such. but, the ouput is not as expected. For example, when I select 1-Apr-22 as date, it is considering below records only

 

RegionCountryRecord DateNo. of Users
EuropeGermany29-Mar-22280
AsiaChina28-Mar-22290

 

That is the date on or before 1-Apr-2022 at Region level. Whereas it should consider at each country level and the sum up at region level.

FreemanZ
Super User
Super User

hi @bobbysasi 

 

your measure shall still work on region level, or?

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors