Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Bratone
Helper I
Helper I

Values depending on date comparison

Hello,

 

I have a situation where depending on the date, I need to take into account one value or another. More pricesely, when rating a person, if the date is > than his promotion date I need to take into account let's say criteria 1, if not, criteria 2, and in the end, when looking at an yearly report, I will need to see the average of both criterias.

 

I have the following formulas:

Criteria 1 = IF(max(Calendar[Date])>[Promo_date],BLANK(),AVERAGE(Score1[Attempt Score1]))

Criteria 2 = IF(MAX(Calendar[Date])>[Promo_date],CALCULATE(average(Score2[Attempt score2]),,BLANK())

Measure = IF(MAX(Calendar[Date])<[Promo_date],[Criteria 1,[Criteria 2]))

Bratone_0-1672923275268.png

The measure on a month-to-month logic seems to be working, but as you can see above, the yearly average is wrong, and I think it takes into account only the scenario when the condition is met for criteria 2.

 

The displayed average is 0.17 just like the value for December, and for this example, the promo date is indeed 1st of December, so it only took into account the values from 1st of December onwards.

 

Any idea how can I make it to also display correctly the yearly average ?

 

Thank you!

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Bratone , Try like

 

Averagex(values(Date[Month Year]), calculate(IF(MAX(Calendar[Date])<[Promo_date],[Criteria 1,[Criteria 2])) )

 

 

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Bratone , Try like

 

Averagex(values(Date[Month Year]), calculate(IF(MAX(Calendar[Date])<[Promo_date],[Criteria 1,[Criteria 2])) )

 

 

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thank you so much for your fast answer, is working as it should now:

 

Bratone_0-1672924759795.png

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.