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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
GeorgiBarov
Frequent Visitor

Average YTD by category

Hi guys,

How can I calculate the average year to date Quantity by Assay?

I have table like:

 

OidAssayQuantityDate
1As0.5746331/1/2016 0:00
2Ag8563.6381/2/2016 0:00
3Au3122.6661/3/2016 0:00
4S240.01461/4/2016 0:00
5Cu3.2078821/5/2016 0:00
6Ag64222.551/6/2016 0:00
7As17.165471/7/2016 0:00
8Cu57.415551/8/2016 0:00

 

Thank you in advance 🙂

1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @GeorgiBarov

 

You could try to create the measure below to get your desired output.

 

average_ytd =
TOTALYTD (
    AVERAGE ( demo[Quantity] ),
    'Table'[Date],
    FILTER ( ALL ( demo ), 'demo'[Assay] = MAX ( 'demo'[Assay] ) )
)

The output is below.

 

Capture.PNG

 

If you need additional help please share your expected output.

 

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.

View solution in original post

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @GeorgiBarov

 

You could try to create the measure below to get your desired output.

 

average_ytd =
TOTALYTD (
    AVERAGE ( demo[Quantity] ),
    'Table'[Date],
    FILTER ( ALL ( demo ), 'demo'[Assay] = MAX ( 'demo'[Assay] ) )
)

The output is below.

 

Capture.PNG

 

If you need additional help please share your expected output.

 

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.

Hi @v-piga-msft and thank you for the reply

I tried your formula but it calculate the AVG([Quantity]) only if there is one [Quantity] per day.
If we have a few records of Quantity related to a one day the formula is wrong.

In the table above Quantity is automaticaly summurized, but actualy there are a few records per day

 

Here are the examples:

Expected value on 01-DEC-2016 / average_ytd is: 205 not 102.5

Thank you 🙂


Capture1.PNGCapture2.PNG

Helpful resources

Announcements
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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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