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
Sankzpower
Helper I
Helper I

Filling gaps with a calculated measure

Hi guys

 

Hope my fellow power bi friends help me. I have a simple table sample which I could easily get it done in excel with the result what I need. However, I cannot seem to get it work in Power BI. Basically, I am filling the gaps and changing value in the value_missing column using a measure with the help of profile column. 

 

1st calculation = (Sum of all Value_missing column) multiply (row Profile value)

2nd Caculation = Sum(Profile column where value_missing is >0)

Final result = 1st Calculation/2nd Calculation

 

Sample file here in excel

 

MonthsProfileValue_MissingNew_Filled1st Calculation2nd CalculationFinal Result
Jan10%74575759979%757
Feb9%86068153979%681
Mar8%47560547979%605
Apr7% 53041979%530
May6%57845436079%454
Jun7%56949238979%492
Jul7%84550740179%507
Aug7%23551440779%514
Sep8% 56744979%567
Oct7%65456044379%560
Nov9%57465852179%658
Dec10%45776460579%764
3 REPLIES 3
AnthonyTilley
Solution Sage
Solution Sage

1st Calculation = 
Var Pr = Sum('Table'[Profile])
var T_VM = CALCULATE(sum('Table'[Value_Missing]),all('Table'))
Var f1 = T_VM * Pr

return f1

 

2nd Calculation = 
var T_VM = CALCULATE(sum('Table'[Profile]),ALL('Table'),'Table'[Value_Missing]>0)

return T_VM

 

Fianl Calculation = DIVIDE([1st Calculation],[2nd Calculation],0)

 

New_Filled = 
Var Pr = Sum('Table'[Profile])
var T_VM = CALCULATE(sum('Table'[Value_Missing]),all('Table'))
Var f1 = T_VM * Pr
var T_PR = CALCULATE(sum('Table'[Profile]),ALL('Table'),'Table'[Value_Missing]>0)
var ret = f1/T_PR
return ret

 

 

new filed.png





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

Proud to be a Super User!




Thanks @AnthonyTilley 

 

I understand the logic behind that now. However, when I tried at my end its not coming up with the same result. I think its because I have got filters on as the one which I have attached is for one ID. I have multiple Ids with Jan - Dec records. I did try the below using your code but it would not work:

 

1st Calculation = 
Var Pr = Calculate(Sum('Table'[Profile]),all('Table'[IDs])
var T_VM = CALCULATE(sum('Table'[Value_Missing]),all('Table'[IDs]))
Var f1 = T_VM * Pr

return f1

 

Hi @Sankzpower ,

 

How about replacing ALL with ALLSELECTED? Can it work?

 

 

Best Regards,

Icey

 

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

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.