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

Reference current filtered measure as a filter in another measure

Hello! I feel like this should be easy but I am new and stuck, your help is much appreciated!!!

 

I have a measure that calcuates the mode price (most recurring number) on a Sales fact table. I need to calculate the Average Units Sold when the Price Per Unit column equals the Mode Price based on the filtered product and customer selection.

 
Mode Price = VAR myTable = SUMMARIZE('Sales Fact','Sales Fact'[Price Per Unit],"Count",COUNT('Sales Fact'[Price Per Unit]))
VAR myTable2 = FILTER(myTable,[Count]=MAXX(myTable,[Count]))
VAR Mode1 = MAXX(LASTNONBLANK(myTable2,[Price Per Unit]),[Price Per Unit])
RETURN Mode1
 
Average Units Sold Mode Price  = CALCULATE(AVERAGE('Sales Fact'[UNIT_SALES]), FILTER('Sales Fact','Sales Fact'[Price Per Unit]=[Mode Price]))
 
 When I do this, it just calculates the average units. How do I pass the actual value of the mode to this filter?
 
Sales Fact
 
CUSTOMER_IDPRODUCT_IDDATEUNIT_SALESPrice Per Unit 
7157010361/7/201814.99
7157010361/14/201844.99
7157010361/21/201834.99
7157010361/28/201874.56
7157010362/4/201844.99
7157010362/11/201844.99
7157010362/18/201824.99
7157010362/25/201834.99
7157010363/4/201864.99
7157010363/11/201824.99
7157010363/18/201853.00
 
 
In this example, the mode correctly returns 4.99
But the Average Units Sold Mode Price measure just returns the average of 3.72
The correct answer should be 3.22
 
I should also mention in my Report, I have two slicers for Customer_ID = 71570 and Product_ID = 1036.
 
 
1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Thank you so much @Ashish_Mathur !! This worked! I also wanted to create a measure for the Average Unit Sales when the price is not the mode. Would you be able to help with that?

You are welcome.  If my previous reply helped, please mark it as Answer.  Try this measure

 

Average units sold at non mode Price = AVERAGEX(FILTER(SUMMARIZE(VALUES(Data[Price Per Unit ]),Data[Price Per Unit ],"ABCD",COUNTROWS(Data),"EFGH",MIN(Data[Price Per Unit ]),"IJKL",AVERAGE(Data[UNIT_SALES])),[ABCD]<>MAXX(SUMMARIZE(VALUES(Data[Price Per Unit ]),Data[Price Per Unit ],"PQRS",COUNTROWS(Data)),[PQRS])),[IJKL])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.