Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Asantos2020
Advocate II
Advocate II

Average Price by Territory, Manufacturer, Brand, Product, Date (DAX)

Hello!

I got the following challenge which I haven't been able to overcome:

 

Territory      Fact   Manufacturer     Brand     Product    Date                  Value
North          Value  A                       X             Item1        12/31/2018      $10

South          Qty     A                       X             Item2        11/30/2018         5
North          Qty     B                       Y             Item3         01/31/2019        2

West           Value  C                       Z             Item4         02/28/2018      $11

 

In order to separate Value from Qty, I created 02 measures:

Value$ = CALCULATE(SUM(MarketShare[Value]);MarketShare[Fact] = "Value")
Volume = CALCULATE(SUM(MarketShare[Value]);MarketShare[Fact] = "Qty")

Simply using:

AvgPrice = (CALCULATE([Value$]/ [Volume]))

...gives me the average price, but when it's displayed on matrix table, with brand as rows and territory as columns.

If I want to use it on a bar chart and selected Territory in the Slicer, then I start getting infinity related errors.

 

Thanks in advance!

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

Hi @Asantos2020 ,

 

I modified your measure as belows:

Value$ = CALCULATE(SUM(MarketShare[Value]),FILTER(ALL(MarketShare),[Fact] = "Value"),VALUES(MarketShare[Territory]))
Volume = CALCULATE(SUM(MarketShare[Value]),FILTER(ALL(MarketShare),[Fact]="Qty"),VALUES(MarketShare[Territory]))
AvgPrice = DIVIDE([Value$],[Volume])
Result shown as below: (AvgPrice will change based on territory)
02.PNG
Community Support Team _ Dina Ye
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-diye-msft
Community Support
Community Support

Hi @Asantos2020 ,

 

I modified your measure as belows:

Value$ = CALCULATE(SUM(MarketShare[Value]),FILTER(ALL(MarketShare),[Fact] = "Value"),VALUES(MarketShare[Territory]))
Volume = CALCULATE(SUM(MarketShare[Value]),FILTER(ALL(MarketShare),[Fact]="Qty"),VALUES(MarketShare[Territory]))
AvgPrice = DIVIDE([Value$],[Volume])
Result shown as below: (AvgPrice will change based on territory)
02.PNG
Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

What if you used the Divide function instead of "/" ?

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors