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
Anonymous
Not applicable

Date Hierarchy Showing Year - Measure & Variance Measure Problem

Hi guys. Long time listener, first time caller.

 

My problem is that I can't get the date hierarchy with just the year showing to sort in descending order, and when I try to switch the header to be a text column of the year it breaks my measures.  I have tried sorting the date hierarchy column and adding a key to sort it properly and neither worked.

 

For my data set, I'm showing current year and prior year data for a measure that is built to only show the MTD and PYMTD.  Here's the formula:

 

MTD =
      var Ldate = Max('Table2'[Date])
      Return(
          CALCULATE(
               SUM(Table1[PostedTotalAMT]), 'Table1'[Date].[MonthNo]= MONTH(Ldate)))
 
I created this formula based on the solution in this post: Link
Note that the Ldate variable and date reference in the formula use different tables.  That needs to be the case for this to work.
 
I have also created a measure that basically uses the same formula, but subtracts the 2018 MTD data from the 2019 MTD data.  I have created a table using both of these measures, with the column headers being the date hierarchy (Table1) with everything taken out besides the year.  Power BI seems to be preventing me from having these columns go in descending order:
 
Power BI Question.PNG
 
When I try changing this to be a text column with the current and prior year and get it correctly sorted, the variance formula bugs out and won't calculate correctly:
 
Power BI Question 2.PNG
 
Does anyone know a way that I could make this work? Thank you in advance...
1 REPLY 1
Cmcmahan
Resident Rockstar
Resident Rockstar

I'm curious about why adding a key to sort it by didn't work. That's what I'd usually recommend for this problem.  Something simple like (0-YEAR([date])) would get you the order you want. How/why did it fail to meet your needs?

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.