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
LowKeyBoy
Regular Visitor

PowerPivot Help Needed Calculating Monthly %'s Only Up To Last Full Month

I  am new to PowerPivot (5 months old) and I thought I was making good progression till I hit this snag.

The data set I am using relates to YTD competitive bids/contract awards that the business either Won or Lost (using Long Date format).
I have managed to expand the data into tables and charts like monthly Win/Lost Count, Win/Lost Percentage, Cumulative Win/Lost Count, Cumulative Win/Lost Percentage, Monthly Win/Lost % Waterfall (Bridge) Charts , Top 10 Win,Top 10 Lost, etc. 

 

As such, when a user request came to create a column graph for individual monthly win percentages (not cumulative) that will only display up to the last full month, I did not envision that it will take me more than 5 minutes to honor; considering I had the measures I will need already created.

But for some reason, it is the nut I cannot crack. Below is what I have tried (and failed)...

 

Graph only displays June/July

=CALCULATE ([Won]/([Won]+[Lost]), DATEADD(FILTER(DATESYTD(Win_Loss[Actual Close Date]), SUM(Calendar[MonthNumberOfYear])>0), +5, MONTH))

 

Graph displays January to August  

=CALCULATE ([Won%], DATEADD(Calendar[Date],-1, Month))

 

Since August is incomplete (in terms of calendar days) I only want the measure to display up to the last full month (i.e. Jan - July only). In September, I want it to show Jan - August only. In other words only looking back to the last full month.

 

Below measure appears to work by displaying up to the last full month (July). However , I would like to have a measure that will not require editing of the month number (in this instance "8"), every month.

=CALCULATE([Won%], Win_Loss[CloseMonthNumber]<8)

Any help will be greatly appreciated.

Many thanks.

 

9 REPLIES 9
GilbertQ
Super User
Super User

My Measure =
VAR PrevMonth = MONTH(EOMONTH(TODAY(),0))
RETURN
CALCULATE([Won%], Win_Loss[CloseMonthNumber]< PrevMonth)

Hi there You could create your measure with the following:





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

Proud to be a Super User!







Power BI Blog

Thanks GilbertQ.

I got an error message related to the 'RETURN' function (below). Kindly advise if I did something wrong.

 

Hi there,

I cannot see the image for some reason, could you possibly post the actual details?




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

Proud to be a Super User!







Power BI Blog

Sure. I used the measure you provided and received an error message as follows:

"The expression is not valid or appears to be incomplete. Please review and correct the expression. The syntax for 'RETURN' is not correct"

Hi @LowKeyBoy,

 

Could you share the screenshots about the formula and the error message?

 

Best Regards,

Cherry

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

Please find image below. Many thanks

image001.png

Hi @LowKeyBoy,

 

It seems that you are using Pivot table in Excel?

 

Based on your screenshots, it seems that you haven't store the result Month(Eomonth(Today(),0)) with VAR so your syntax is incorrect for RETURN.

 

In addition, please note the VAR function is supported for SQL Server 2016 Analysis Services (SSAS), Power Pivot in Excel 2016, and Power BI Desktop only.

 

Best Regards,

Cherry

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

Thanks Cherry; yes I am using PowerPivot in Excel 2013...

Below measure appears to work by displaying up to the last full month (July). However , I would like to have a measure that will not require editing of the month number (in this instance "8"), every month.

=CALCULATE([Won%], Win_Loss[CloseMonthNumber]<8)

Any help will be greatly appreciated.

Many thanks.

This should be able to do it

 

My Measure =
VAR MonthNumber = MONTH(TODAY())
RETURN
CALCULATE([Won%], Win_Loss[CloseMonthNumber] < MonthNumber )




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

Proud to be a Super User!







Power BI Blog

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
Top Kudoed Authors