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
DearestYoki
Frequent Visitor

Field<>BLANK() Doesn't Work after Sorting the Field by Another Column

Hi all,

 

I encountered an issue while changing the sorting order of axis & legend.

 

The measure I created is [%SOM] (i.e. share of market) and the expression is as follow:

IF(SELECTEDVALUE(Filter1[Period1])="L6M",
CALCULATE(SUMX(FILTER(Raw1,Raw1[Level]="Item"),Raw1[Volume/Value]),DATESBETWEEN('Calendar'[Date],[L6M Start],[PeriodEnd]))/
CALCULATE(SUMX(FILTER(Raw1,Raw1[Level]="Item"),Raw1[Volume/Value]),DATESBETWEEN('Calendar'[Date],[L6M Start],[PeriodEnd]),MASTER_PRODUCT[Corp.]<>BLANK()),

The full expression is very long with multiple if statements for different periods. Now I am only showing a portion of it. After applying Master_Product[Corp.] as axis, the expression is basically calculationg volume/value of individual corp divided by volume/value for all corps. The reason why I didn't use ALL(corp.) is I don't want to take rows with empty corp. but valid volume/value into account.

The chart will look like this:

2.PNG

In this chart, all percentages sum up equals to 100%, which validates the expression above. However, the axis is in alphabetical order. I have created sorting index column for each Corp. in the same table using power query editor.

1.PNG

However, after I apply "Sort by Column", the order of Corp. appears correctly but the measure becomes wrong. All [%SOM] give me 100% as the result.

3.PNG

I think after applying sort by column on Corp., the filter Corp. <> BLANK() no longer works properly. I have done some research about this and found similar issue posted before regarding ALL() function, but the fix for that one doesn't work for me.

 

It would be great if any of you can help me with this. Thanks so much!

 

Best Regards,

Yoki

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@DearestYoki, See if this formula can help

IF(SELECTEDVALUE(Filter1[Period1])-"L6M",
CALCULATE(SUMX(FILTER(Raw1,Raw1[Level]-"Item"),Raw1[Volume/Value]),DATESBETWEEN('Calendar'[Date],[L6M Start],[PeriodEnd]))/
CALCULATE(SUMX(FILTER(Raw1,Raw1[Level]-"Item"),Raw1[Volume/Value]),DATESBETWEEN('Calendar'[Date],[L6M Start],[PeriodEnd]),
filter(allselected(MASTER_PRODUCT),MASTER_PRODUCT[Corp.]<>BLANK())))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@DearestYoki, See if this formula can help

IF(SELECTEDVALUE(Filter1[Period1])-"L6M",
CALCULATE(SUMX(FILTER(Raw1,Raw1[Level]-"Item"),Raw1[Volume/Value]),DATESBETWEEN('Calendar'[Date],[L6M Start],[PeriodEnd]))/
CALCULATE(SUMX(FILTER(Raw1,Raw1[Level]-"Item"),Raw1[Volume/Value]),DATESBETWEEN('Calendar'[Date],[L6M Start],[PeriodEnd]),
filter(allselected(MASTER_PRODUCT),MASTER_PRODUCT[Corp.]<>BLANK())))

Thanks! Your solution works perfectly 🙂

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.