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

Sort Order Impacting Measures

I have a dataset which has This Year and Year Ago data. I used a table to provide the sorting order for the same using a relationship and relation function. Post this I sorted TY/YA columns based on the new column with sort order. But as soon as I did that my change measures (TY/YA-1) stopped working and started giving me error. Has anyone faced a situation like this?

 

8 REPLIES 8
dax
Community Support
Community Support

Hi @Anonymous , 

I am not clear about your requirement and your data structure, if possible could you please inform me more detailed information(such as your expected output and your sample data)? Then I will help you more correctly.

Please do mask sensitive data before uploading.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

My sample data looks like this:

Time PeriodBrandSales
TYB1100
YAB1100
YAB21110
TYB2

1100

Hi

Apologies for the bad explanation of the problem

 

Situation:

I was using a measure to calculate change in sales: Sales(TY)/Sales(YA)-1. It was working perfectly.

Problem:

However, when I was plotting a clustered column chart with brands in axis and TY/YA as legends and value. I couldn't control the TY/YA.

Hence, I created a table with index of TY as 2 and YA as 1. I used related function to bring the index values to the sales table after creating relationship on Time Period. Then I sorted column Time Period on basis of Index. This is when my change measures stopped working and started giving me error.

 

I am a newbie in DAX, please can you help me by pointing out what did I do wrong in this case?

 

dax
Community Support
Community Support

Hi @Anonymous , 

I think this can't sort by legend column(it seems to be related to value and axis ). In addition, if possible, could you please inform me your expected output? Then I will help you more correctly.

 

Please do mask sensitive data before uploading.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Anonymous
Not applicable

Capture.PNG

 

I want to bring change the order of legends from TY/YA to YA/TY. Hence, I had used the re-ordering using a index column. However, as soon as I brought in the index column and sorted the TY/YA column basis index my change measures stopped working and gave error.

 

dax
Community Support
Community Support

Hi @Anonymous , 

I don't know your error when you use legend index, I test this in my environment, I create relationship between them , and set sort by "ORDER", it works.

629.PNG

 

So I don't know  which cause this problem. If possible, could you please inform me your sample data or pbix(recommend to use OneDrive for Business, and you could use virtual data instead of real data)

Please do mask sensitive data before uploading.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Can you try to see if this DAX works in your case:

Chg Value Share = IFERROR((calculate(sum(Data[Sales]),Data[Time Period]="TY")/
(calculate(sum(Data[Value Sales]),Data[Time Period]="YA"))-1,"")

amitchandak
Super User
Super User

@Anonymous , how is TY, LY created. Are they created using date calendar and common time intelligence? Using datesytd, totalytd. Example

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"12/31"))
This Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD((ENDOFYEAR('Date'[Date])),"12/31"))

Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
Last YTD complete Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Greg_Deckler
Super User
Super User

Not at all clear, Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.