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

Measure with denominator that only filters on certain values

Below left is example of my data set. I want to create the visual on the right. I can create everything except the % Sales measure. I feel like I'm close but I'm not an expert and need help! 

Picture3.jpg

I feel like I need to do something in the denominator of the DIVIDE, somehow keeping the filters for Location, Category, Attribute Type, and Attribute (although note that Attribute is not shown in visual), but NOT filtering on the Attribute Value. In other words, the denominator needs to include both the positive and negative Attribute Values...AKA the whole Attribute.

 

Help!

-Mike

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @NewbNeedHelp 

 You can put the fields into the table visual , then apply the following visual filters:

vxinruzhumsft_0-1670218593294.png

 

Then you can create a new measure, the code is as follows:

%Sales = var a=FILTER(ALL('Table'),'Table'[Attribute]=SELECTEDVALUE('Table'[Attribute])) var b=FILTER(ALL('Table'),'Table'[Attribute]=SELECTEDVALUE('Table'[Attribute])&&CONTAINSSTRING('Table'[Attribute Value],"Not")=FALSE()) return DIVIDE(SUMX(b,[Sales]),SUMX(a,[Sales]))

Output:

vxinruzhumsft_1-1670218593303.png

 

 

Best Regards,

Yolo Zhu

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

View solution in original post

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi @NewbNeedHelp 

 You can put the fields into the table visual , then apply the following visual filters:

vxinruzhumsft_0-1670218593294.png

 

Then you can create a new measure, the code is as follows:

%Sales = var a=FILTER(ALL('Table'),'Table'[Attribute]=SELECTEDVALUE('Table'[Attribute])) var b=FILTER(ALL('Table'),'Table'[Attribute]=SELECTEDVALUE('Table'[Attribute])&&CONTAINSSTRING('Table'[Attribute Value],"Not")=FALSE()) return DIVIDE(SUMX(b,[Sales]),SUMX(a,[Sales]))

Output:

vxinruzhumsft_1-1670218593303.png

 

 

Best Regards,

Yolo Zhu

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

Thank you so much!! This worked! 🙂

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.