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
MorePowerBI
Helper II
Helper II

Need help with a measure to calculate weekly rates

Can someone help me create a measure that generates the WeeklyRate column below?

The calculation is [Loss] divided by the sum of [StartQtySx] for the week.

 

IDStart of WeekStartQtySxLossWeeklyRate
53125216/5/20225600851851.24%
53125226/5/20225584073891.76%
53125236/5/202254632166133.96%
53125246/5/20224176070821.69%
53125256/5/20223172819460.46%
53125266/5/20224987228920.69%
53125276/5/20225573766281.58%
53125286/5/20223812842231.01%
53127076/5/20223549646771.12%
53126095/29/20224235155401.82%
53126215/29/20223351346321.52%
53126345/29/20225553267602.22%
53126475/29/20225231457281.88%
53126605/29/20223334138721.27%
53126735/29/20223753927370.90%
53126865/29/20224981441281.36%

MorePowerBI_0-1655437292204.png

 

 

I'm using this measure but it's giving me different numbers

WeeklyRate =
VAR Numerator[Loss]
VAR Denominator
CALCULATE ( [StartQtySx],
ALLEXCEPT ( 'Table', Table[Start of Week] )
)
RETURN
Numerator / Denominator
 
Help is greatly appreciated!
 
[Edit]
The above calculation actually works.
1 ACCEPTED SOLUTION

Are you creating a measure or column.. you should create a measure 

m_WeeklyRate = 
VAR Numerator = SUM('Table'[Loss])
Var Denominator = CALCULATE ( SUM([StartQtySx]),ALLEXCEPT ( 'Table', 'Table'[Start of Week] ))
RETURN
Numerator/Denominator






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

Proud to be a Super User!




View solution in original post

5 REPLIES 5
FarhanAhmed
Community Champion
Community Champion

The results seems correct to me.

Can you please explain what results you are expecting as

5185/419201 returns = 1.24% for the first value and vice versa for the all week

similarly for the previous week 5540/304404  returns = 1.82% and vice versa for the all week

 

 







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

Proud to be a Super User!




This is what PBI desktop is giving me.

 

MorePowerBI_0-1655441489332.png

 

Notice the WeeklyRate is incorrect.

m_WeeklyRate = 
VAR Numerator = SUM('Table'[Loss])
Var Denominator = CALCULATE ( SUM([StartQtySx]),ALLEXCEPT ( 'Table', 'Table'[Start of Week] ))
RETURN
Numerator/Denominator






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

Proud to be a Super User!




Are you creating a measure or column.. you should create a measure 

m_WeeklyRate = 
VAR Numerator = SUM('Table'[Loss])
Var Denominator = CALCULATE ( SUM([StartQtySx]),ALLEXCEPT ( 'Table', 'Table'[Start of Week] ))
RETURN
Numerator/Denominator






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

Proud to be a Super User!




It's a column.

 

I tried it with a measure instead but getting the same incorrect values.

 

[Edit]
Nevermind, I needed to filter the dataset. The measure and column both work after this.

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.