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

Percentages

I am a Power BI newbie and am wondering how to best calculate a percentage of some values and then use the percentages in other calculations.

 

I currently have two data tables:  one for River Operating Hours (by vessel), and another for Total Monthly Operating Days (by vessel).  I'm looking to calculate the percent each river is of the vessel total and multiply that by Total Monthly Operating Days to arrive at River Operating Days.

 

I've included sample data below.....  Any assistance would be greatly appreciated!!!

 

Best,

MAC

 

Hours Table:    Oper Days Table  
Month_yearVessselRiverHrs Month_yearVessselDays
Jan-16JamesRed400 16-JanJames31
Jan-16JamesYellow100 16-JanPeter31
Jan-16JamesBlue125    
Jan-16JamesGreen119    
Jan-16PeterRed250    
Jan-16PeterYellow150    
Jan-16PeterBlue100    
Jan-16PeterGreen244    
        
        
        
River_Days: - Desired      
Month_yearVessselRiverOper_Days    
16-JanJamesRed16.66666667    
16-JanJamesYellow4.166666667    
16-JanJamesBlue5.208333333    
16-JanJamesGreen4.958333333    
16-JanPeterRed10.41666667    
16-JanPeterYellow6.25    
16-JanPeterBlue4.166666667    
16-JanPeterGreen10.16666667    
1 ACCEPTED SOLUTION

Hi @MAC,

 

You need to create a calculate column to return Days value from the Oper Days Table in Hours Table:

 

Days = LOOKUPVALUE('Oper Days'[Days],'Oper Days'[Month_year],'Hours'[Month_year],'Oper Days'[Vesssel],'Hours'[Vesssel])

 

Then create a calculated column to return Oper_Days:

 

River Percent = SUM([Hrs])/CALCULATE(SUM([Hrs]),ALLEXCEPT(Hours,Hours[Vesssel],'Hours'[Month_year]))

 

q6.PNG

 

Please check attached .pbix.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
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
MAC
Frequent Visitor

Thank you!

 

Can I still use ALLEXCEPT if I have more than one layer of date data?

 

Hours Table:    Oper Days Table  
Month_yearVessselRiverHrs Month_yearVessselDays
Jan-16JamesRed400 Jan-16James31
Jan-16JamesYellow100 Jan-16Peter31
Jan-16JamesBlue125 Feb-16James29
Jan-16JamesGreen119    
Jan-16PeterRed250    
Jan-16PeterYellow150    
Jan-16PeterBlue100    
Jan-16PeterGreen244    
Feb-16JamesRed130    
Feb-16JamesYellow180    
Feb-16JamesBlue250    
Feb-16JamesGreen136    
        
        
River_Days: - Desired      
Month_yearVessselRiverOper_Days    
Jan-16JamesRed16.66666667    
Jan-16JamesYellow4.166666667    
Jan-16JamesBlue5.208333333    
Jan-16JamesGreen4.958333333    
Jan-16PeterRed10.41666667    
Jan-16PeterYellow6.25    
Jan-16PeterBlue4.166666667    
Jan-16PeterGreen10.16666667    
Feb-16JamesRed5.416666667    
Feb-16JamesYellow7.5    
Feb-16JamesBlue10.41666667    
Feb-16JamesGreen5.666666667    

Hi @MAC,

 

You need to create a calculate column to return Days value from the Oper Days Table in Hours Table:

 

Days = LOOKUPVALUE('Oper Days'[Days],'Oper Days'[Month_year],'Hours'[Month_year],'Oper Days'[Vesssel],'Hours'[Vesssel])

 

Then create a calculated column to return Oper_Days:

 

River Percent = SUM([Hrs])/CALCULATE(SUM([Hrs]),ALLEXCEPT(Hours,Hours[Vesssel],'Hours'[Month_year]))

 

q6.PNG

 

Please check attached .pbix.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks so much!!!!!

Greg_Deckler
Super User
Super User

I created a Measure like so:

 

River Percent = SUM([Hrs])/CALCULATE(SUM([Hrs]),ALLEXCEPT(Hours,Hours[Vesssel]))

And then a calculated column in Hours table like so:

 

Oper_Days = [River Percent]*CALCULATE(SUM('Oper Days'[Days]),RELATEDTABLE('Oper Days'))

@ 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
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.