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

measure to distribute specific row share among the other row values as per share percentage

I have a data something like below table, and the need is to distribute the blank tag cost among the other tag according to their related share of not blank value. Example..

 

tagcost
aaa100
bbb10
ccc40
ddd50
(blank)80
bbb60
ccc30
ddd20
aaa40
(blank)500
(blank)100

 

Expected calculation

 

for aaa the share will be "140/(100+20+30+50+60+30+20+40)" = 40% of 680

for bbb the share will be  "70/(100+20+30+50+60+30+20+40)" = 20% of 680

for ccc the share will be "70/(100+20+30+50+60+30+20+40)" = 20% of 680

for ddd the share will be "70/(100+20+30+50+60+30+20+40)" = 20% of 680

 

expected solution

 

tagcost%sharetotal Share
aaa14040% of 680272
bbb7020% of 680136
ccc7020% of 680136
ddd7020% of 680136

 

 

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

Hi @anuj_a ,

According to your description, here’s my solution.

  1. %share = DIVIDE(SUM([cost]),SUMX(FILTER(ALL('Table'),NOT(ISBLANK([tag]))),[cost]))
  2.  total share = SUMX(FILTER(ALL('Table'),ISBLANK([tag])),[cost])*[%share]
  3.  Unselect blank

vkalyjmsft_0-1636452879013.jpeg

 

Best Regards,
Community Support Team _ kalyj

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

thanks @v-yanjiang-msft  and @Greg_Deckler - your solutions worked with my POC data, however my prod data with more filters and columns has some problems with this solution. 
May be I will share more relavant dummy data other time on separate question. for this query I am good. thanks for your assistance.  

v-yanjiang-msft
Community Support
Community Support

Hi @anuj_a ,

According to your description, here’s my solution.

  1. %share = DIVIDE(SUM([cost]),SUMX(FILTER(ALL('Table'),NOT(ISBLANK([tag]))),[cost]))
  2.  total share = SUMX(FILTER(ALL('Table'),ISBLANK([tag])),[cost])*[%share]
  3.  Unselect blank

vkalyjmsft_0-1636452879013.jpeg

 

Best Regards,
Community Support Team _ kalyj

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

 

.

Greg_Deckler
Super User
Super User

@anuj_a Seems like:

Measure = 
  VAR __Total = SUMX(FILTER(ALL('Table'),[tag]<>BLANK()),[cost])
  VAR __BlankTotal = SUMX(FILTER(ALL('Table'),[tag]=BLANK()),[cost])
  VAR __TagTotal = SUM('Table'[cost])
  VAR __Percent = DIVIDE(__TagTotal,__Total,0)
RETURN
  __TagTotal + __Percent * __BlankTotal

Follow on LinkedIn
@ 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...

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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

Top Solution Authors