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

Cost of Oppotunity

Hello to all,

 

I have come to my personal limit with DAX...

 

I am trying get the cost of opporinity from each store. By cost of oppotunity I meen the stores that dont have disponibility of one product, look for the average sales of this product from the other stores and sum this as "Lost Sales".

 

It sounds simple but I dont have any clue how to formulate this in DAX...

 

Example:

Example.jpg

 

I hope you can help me Smiley Happy

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

Hi @Anonymous,

 

In your scenario, you can create a measure like below:

 

Lost Sales = IF(MIN('storetable'[Disponibility])=0,
CALCULATE(SUM(storetable[Sales value]),ALLSELECTED( storetable ), VALUES( storetable[Product] ))/CALCULATE(COUNT(storetable[Sales value]),ALLSELECTED( storetable ), VALUES( storetable[Product] )),BLANK())

 

Then you can place "Store" field in a slicer visual, check different values to filter table data.

 

z1.PNGz2.PNG

 

Best Regards,

Qiuyun Yu

Community Support Team _ Qiuyun Yu
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

4 REPLIES 4
v-qiuyu-msft
Community Support
Community Support

Hi @Anonymous,

 

In your scenario, you can create a measure like below:

 

Lost Sales = IF(MIN('storetable'[Disponibility])=0,
CALCULATE(SUM(storetable[Sales value]),ALLSELECTED( storetable ), VALUES( storetable[Product] ))/CALCULATE(COUNT(storetable[Sales value]),ALLSELECTED( storetable ), VALUES( storetable[Product] )),BLANK())

 

Then you can place "Store" field in a slicer visual, check different values to filter table data.

 

z1.PNGz2.PNG

 

Best Regards,

Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
richbenmintz
Solution Sage
Solution Sage

I think you are a trying to do the something like the following:

measure=if(hasonevalue(storetable'[store]), divide(calculate(sum('table'[salesColumn]), filter(all('storetable'), 'storetable'[store] <> values('storetable'[store]))), calculate(sum('table'[ordercount]), filter(all('storetable'), 'storetable'[store] <> values('storetable'[store]) ))), blank())

 

you could also use a variable to store the filtered table to make the code a bit cleaner, but that would be a little more complicated.

 

Hope that helps



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Anonymous
Not applicable

Hi richbenmintz,

 

Thank you very much for the fast repley.

 

It looks like its working but only if I select a single store with a slicer, otherwise I cant view the measure...

 

Is there a way to view it for all the stores at the same time?

correct the measure will only work if there is a single store in the filter context. if you add store to rows or columns then you will be able to use multiple stores in your slicer



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


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.