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

Summarize by max over multiple line and sum the value

I want to cacluate the % of qty submitted out of total qty.

I have multipule line for bill no. 1 in my dataset due to data issue. However, whenever there are date appear in any line, I will consider bill no. 1 as submitted.  Thus, my expected result is 200/300 = 66.7% but now in the measure I made, it is showing 150/300 = 50%. Can anyone have any clue how the measure should be written?

 

Bill no.Submitted Dateqty
11/12/201950
1 30
1 20
23/12/2019100
3 100
2 ACCEPTED SOLUTIONS
v-kelly-msft
Community Support
Community Support

Hi @questions

 

You need a measure as below:

 

Measure = 
var a =IF(MAX('Table'[Submitted Date])<>BLANK()&&MAX('Table'[Index])<>1,CALCULATE(SUM('Table'[qty]),FILTER(ALL('Table'),'Table'[Index]<=SELECTEDVALUE('Table'[Index]))),BLANK())
var b = SUMX(ALL('Table'),'Table'[qty])
Return
a/b

 

 

Finally you will see:

 

Annotation 2020-04-03 103357.png

 

For the related .pbix file,pls click here.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

 

View solution in original post

Thanks!! it works but i just finetuning a bit so it works out...Here it is in case other users need this information.

 

measure =
var _tab = summarize(Table[Bill No], "_Date",firstnonbank(table[Submitted Date],0),"_qty",sum(table[Qty])
)
return
divide(sumx(_tab,if(not(isblank([_Date])),[_qty],0),sumx(_tab,[_qty]))

View solution in original post

4 REPLIES 4
v-kelly-msft
Community Support
Community Support

Hi @questions

 

You need a measure as below:

 

Measure = 
var a =IF(MAX('Table'[Submitted Date])<>BLANK()&&MAX('Table'[Index])<>1,CALCULATE(SUM('Table'[qty]),FILTER(ALL('Table'),'Table'[Index]<=SELECTEDVALUE('Table'[Index]))),BLANK())
var b = SUMX(ALL('Table'),'Table'[qty])
Return
a/b

 

 

Finally you will see:

 

Annotation 2020-04-03 103357.png

 

For the related .pbix file,pls click here.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

 

amitchandak
Super User
Super User

@questions ,

Try like

measure =
var _tab = summarize(Table[Bill No], "_Date",firstnonbank(table[Submitted Date]),"_qty",sum(table[Qty])
)
return
divide(sumx(_tab,if(not(isblank[_Date])),[_qty],0),sumx(_tab,[_qty]))

Thanks!! it works but i just finetuning a bit so it works out...Here it is in case other users need this information.

 

measure =
var _tab = summarize(Table[Bill No], "_Date",firstnonbank(table[Submitted Date],0),"_qty",sum(table[Qty])
)
return
divide(sumx(_tab,if(not(isblank([_Date])),[_qty],0),sumx(_tab,[_qty]))

Hi @questions ,

 

Good job,so is your issue solved?Can you mark the reply as answered to close it?

 

Much appreciated.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

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.

Top Solution Authors