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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
AdrianSantos___
Regular Visitor

Sorting month axis by last available month

Hello everyone,

 

I work with a shared PowerBI dataset with read-only permission, therefore I cannot edit or format any fields. The dataset does not have a dimensional table for date, all dates are fields within the fact table. Dates are formatted as Date/Time therefore will show up with either as a hierachy (4 fields) or a full date with time included.

 

AdrianSantos____0-1649262566095.pngAdrianSantos____1-1649262566098.png

 

 

I need to build a graph that will show me data from the last 12 months but I want it to be dynamic. For instance, if I build the report in April I want the data to show me April, March, February, etc. in a moving annual total perspective.

 

The problem is that if I build a graph with a date hierarchy and drill to Month, it will always order the months from Jan to Dec. In the example below I have data until 31st of March, but the graph will always order it with January first.

AdrianSantos____2-1649262566100.png

 

Is there a way to order the axis in terms of the latest available month? I believe that even if I had a column with Month only it would not automatically sort.

 

Thank you !

1 ACCEPTED SOLUTION
tackytechtom
Super User
Super User

Hi @AdrianSantos___ ,

 

How about creating a SortOrder measure which you can use a tooltip to sort your graph on:

MeasureOrderMonth = 
VAR _currentMonth = MONTH ( TODAY() )
VAR _dataMonth = MONTH ( MAX ( Table[Date] ) )
RETURN
IF ( _currentMonth  >= _dataMonth,  (_dataMonth  - _currentMonth + 12) * 10, _dataMonth ) 

 

If the current month was April, _currentMonth would be 4. 

If the data was April, _dataMonth would be 4.

--> MeasureOrderMonth returns 120

 

If the current month was April, _currentMonth would be 4. 

If the data was March, _dataMonth would be 4.

--> MeasureOrderMonth returns 110

 

If the current month was April, _currentMonth would be 4. 

If the data was February, _dataMonth would be 2.

--> MeasureOrderMonth returns 100

 

If the current month was April, _currentMonth would be 4. 

If the data was January, _dataMonth would be 1.

--> MeasureOrderMonth returns 90

 

If the current month was April, _currentMonth would be 4. 

If the data was December, _dataMonth would be 12.

--> MeasureOrderMonth returns 12

 

If the current month was April, _currentMonth would be 4. 

If the data was November, _dataMonth would be 11.

--> MeasureOrderMonth returns 11

 

etc.

 

Does this work for you? 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/

 



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

1 REPLY 1
tackytechtom
Super User
Super User

Hi @AdrianSantos___ ,

 

How about creating a SortOrder measure which you can use a tooltip to sort your graph on:

MeasureOrderMonth = 
VAR _currentMonth = MONTH ( TODAY() )
VAR _dataMonth = MONTH ( MAX ( Table[Date] ) )
RETURN
IF ( _currentMonth  >= _dataMonth,  (_dataMonth  - _currentMonth + 12) * 10, _dataMonth ) 

 

If the current month was April, _currentMonth would be 4. 

If the data was April, _dataMonth would be 4.

--> MeasureOrderMonth returns 120

 

If the current month was April, _currentMonth would be 4. 

If the data was March, _dataMonth would be 4.

--> MeasureOrderMonth returns 110

 

If the current month was April, _currentMonth would be 4. 

If the data was February, _dataMonth would be 2.

--> MeasureOrderMonth returns 100

 

If the current month was April, _currentMonth would be 4. 

If the data was January, _dataMonth would be 1.

--> MeasureOrderMonth returns 90

 

If the current month was April, _currentMonth would be 4. 

If the data was December, _dataMonth would be 12.

--> MeasureOrderMonth returns 12

 

If the current month was April, _currentMonth would be 4. 

If the data was November, _dataMonth would be 11.

--> MeasureOrderMonth returns 11

 

etc.

 

Does this work for you? 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/

 



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.