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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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