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
Anonymous
Not applicable

Calculate Value based on Max & Criteria in Dimension

Hi PBI Experts!

 

Update:

Seems that there's some bug or problem, re-opened the file today (nothing was changed, data wasn't refreshed) but the values reflect correctly this time

 

I have something I can't get my head around, hope someone can help

 

My Table consists of Version, Period, Item & Value where:

  • Each Period has multiple versions (e.g. Forecast, Week "X", Working)

buckbeak_0-1615997194325.png

 

I am trying to create a table (see the lower table) whereby when a Period is selected, the table shows:

  • The corresponding value for Version = "Working"
  • The corresponding value for the Latest Week (in this case "Week 3"), however I can't achieve this portion

buckbeak_1-1615997423557.png

 

My attempt to create "Value_LatestWeek" that failed is:

  1. Create a measure to identify the latest week
    • LATEST_WEEK = CALCULATE(MAX(Table1[Version]),FILTER(Table1,LEFT(Table1[Version],4) = "WEEK"))
  2. Create a measure to calculate value based on "LATEST_WEEK"
    • Value_LatestWeek = CALCULATE([Value],FILTER(Table1,Table1[Version] = [LATEST_WEEK] ))

Strangest thing is even though "LATEST_WEEK" correctly identifies as "Week 3", "Value_LatestWeek" adds up all values that belong to all the weeks

 

VersionPeriodItem Value 

ForecastQ1 2021Revenue                 45,000
ForecastQ1 2021Cost of Materials                 37,500
ForecastSep FY 21Revenue                 15,000
ForecastSep FY 21Cost of Materials                 13,000
ForecastOct FY 21Revenue                 14,000
ForecastOct FY 21Cost of Materials                 12,500
ForecastNov FY 21Revenue                 16,000
ForecastNov FY 21Cost of Materials                 12,000
Week 1Q1 2021Revenue                 43,000
Week 1Q1 2021Cost of Materials                 37,000
Week 1Sep FY 21Revenue                 14,500
Week 1Sep FY 21Cost of Materials                 12,000
Week 1Oct FY 21Revenue                 13,500
Week 1Oct FY 21Cost of Materials                 13,000
Week 1Nov FY 21Revenue                 15,000
Week 1Nov FY 21Cost of Materials                 12,000
Week 2Q1 2021Revenue                 48,000
Week 2Q1 2021Cost of Materials                 42,000
Week 2Sep FY 21Revenue                 16,000
Week 2Sep FY 21Cost of Materials                 14,500
Week 2Oct FY 21Revenue                 17,000
Week 2Oct FY 21Cost of Materials                 15,000
Week 2Nov FY 21Revenue                 15,000
Week 2Nov FY 21Cost of Materials                 12,500
WorkingQ1 2021Revenue                 42,500
WorkingQ1 2021Cost of Materials                 37,000
WorkingSep FY 21Revenue                 15,500
WorkingSep FY 21Cost of Materials                 14,000
WorkingOct FY 21Revenue                 13,500
WorkingOct FY 21Cost of Materials                 12,000
WorkingNov FY 21Revenue                 13,500
WorkingNov FY 21Cost of Materials                 11,000
1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Try this

Value_LatestWeek = CALCULATE([Values],FILTER(Data,Data[Version] = CALCULATE(MAX(Data[Version]),FILTER(Data,LEFT(Data[Version],4) = "WEEK"))))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Try this

Value_LatestWeek = CALCULATE([Values],FILTER(Data,Data[Version] = CALCULATE(MAX(Data[Version]),FILTER(Data,LEFT(Data[Version],4) = "WEEK"))))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Thanks for your answer, seems like today when I open the file, the calculated value from my original file is reflecting the right numbers...

 

Not sure if there was some bug or memory problem on my PC? But your calculation works as well

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Appreciate any help!

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.