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
tjapka
Regular Visitor

using max value measure as filter for other calculated measure

 Good day, good people! Pls help me to solve not so difficult, but tricky case:

 

1) I need to get unique weight value of 0.10, that corresponds to the maximum value of 11 072.74 as filter (for region Latvia). In other words, I need to recognize, that maximum value of sales is for Latvia (11 072,74) and relate weight value for that region - 0,10 - for all other countries (desirable result).

 

  • Max_reg=CALCULATE(MAXX(ALL(Region[Region]);raw[Sec_Value])) - here I find max for sum of Sales for every region;
  • Weight_max_reg='market IQVIA'[Market]/(CALCULATE(sum('market IQVIA'[Sum TRD Price in EURO]);ALL(Region[Region]))) - here i calculate % of market allocation for every region;
  • I need to get the constant weight value, based on regional maximum of sales value.
RegionSalesMax_regWeight_max_regDesirable result
Spain9 631,87

11072,74

0,150,10
Latvia11072,7411072,740,100,10

 

Pls help me to solve it, I have no idea...

7 REPLIES 7
Greg_Deckler
Super User
Super User

Should be something along the lines of:

 

Max_reg_weight = CALCULATE(MAX(Table[Weight_max_reg]),FILTER(Table,Table[Sales]=[Max_reg]))

A lot of assumptions made here. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Dear Grag, thank you for your reply, but unfortunately weight max reg is calculated measure...

(Table[Weight_max_reg])

 

Oh, then it's just:

 

Max_reg_weight = CALCULATE([Weight_max_reg],FILTER(Table,Table[Sales]=[Max_reg]))

See my comment above about a lot of assumptions, that was one of them. This is why you should read my post here: Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Dear Greg, thank you for your patience, bet this formula gives simply weight measure for every region, not the constant,depending on maximum of sales value (exactly sum of sales).

I put it like this and get real weight for each region...

=CALCULATE('market IQVIA'[Weight_Value];FILTER(raw;raw[Sec_Value]=raw[Potential_max_reg]))

 

Pls help me to cope this!

 

Would love to help more, but need source data to replicate this properly. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

PP_table.JPG

Dear Greg! This is how Power Pivot table looks like. Sec Value is measure (simple sum of sale), Potential_max_reg is calculated as maximum value of sum of Sec Value, Weight is measure. Weght_max_reg - i need to calculate, where this measure should be calculated (filtered) from the maximum sales (11 073, Latvia - Sec Value) and show me unique weight for Latvia (0.10 - Weight_Value) in every region as constant value. Thank you in adv. If you need anything else, pls let me know.

 

1) table name - raw

table_raw.JPG

used in followin formulas:

Potential_max_reg:=CALCULATE(MAXX(ALL(Region[Region]);raw[Sec_Value])) - i use it for calculation, where Region - is for Region table (classifier);

Sec_Value:=CALCULATE(sum([SecEUR])) - formula shown in prior calculation (raw[Sec_Value])

 

2) table name - market IQVIA

IQ Via.JPG

used in followin formulas:

Market:=CALCULATE(SUM([Sum TRD Price in EURO])) - i use it for calculation below

Weight_Value:='market IQVIA'[Market]/(CALCULATE(sum('market IQVIA'[Sum TRD Price in EURO]);ALL(Region[Region])))

 

3) this is powerpivot table, where I need to get result of weight_max_reg, that is connected to maximum value and shows unique weight value (0.10) for all regions as constant.

PP_table.JPG

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.