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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

MAA - Calculation

Dear all,

I'm trying to calculate the MAA (Moving Annual Average) value - but I would need your help on this KPI & DAX language.

Data are like this:

-> Conformity level (Grade A = OK/NON OK per scan/factory/etc.).

 

So I would need to calculate the average of grade A on the last 13 periods. 

 

yearCONFORMITYPeriodFactories
2020OKP13RCA
2020OKP13RCA
2020OKP13RCA
2021OKP01RFT
2021WRNG_NOKP01RFT
2021OKP02RNI
2021OKP02RNI
2021OKP02RNI
2021OKP02RNI
2021OKP02RNI

 

% Grade A from the last 13 periods -> Total Count OK/(Conform + WRNG + NON OK)*100 from the last 13 periods

Above is an exemple (the 13 periods are missing) -> expected results = 90 %

 

Thanks for your help

Hervé

7 REPLIES 7
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

The basis for processing the same ranking, skip stands for sparse ranking, and the next ranking is equal to the number of all previous rankings + 1; dense stands for dense ranking, which only accumulates the ranking, regardless of the number. Use skip by default. ASC stands for ascending order, DESC is used by default.

 

I did a test, it can be used as a reference:

M1 = RANKX('Table',[Value],,ASC,Dense)
M2 = RANKX('Table',[Value],,ASC,Skip)

vhenrykmstf_0-1623900412049.png

 

For specific formulas, please refer to the blog link provided by me:RANKX – DAX Guide


Best Regards,
Henry

If this post also helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hello

If you take my example above, what do you mean by "value"?

Thanks

Hervé

Hi @Anonymous ,

 

The "value" field is the column I need to sort.


Best Regards,
Henry

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hello,

And more baiscally can I use this formula:

YTD 2021 = Divide(CALCULATE(COUNTROWS(rclms_qa), FILTER(rclms_qa,rclms_qa[CONFORMITY]="OK"&&rclms_qa[Mars Year]=2021)),CALCULATE(COUNTROWS(rclms_qa), FILTER(rclms_qa,rclms_qa[Mars Year]=2021)))*100
 
And get the results (adding a DAX formula) of the last 13 periods (from today until the last 13 periods).
Thanks
Hervé

Hi @Anonymous ,

 

Yes, your formula is also a good way. If the problem has been solved or my reply provided you with help, you can mark it as the correct answer to to help the other members find it more quickly.😊


Best Regards,
Henry

amitchandak
Super User
Super User

@Anonymous , First create a separate year period table with period rank column and join both on yearperiod combine column

 

Period Rank = RANKX(all('Period'),'Period'[year period],,ASC,Dense)

 

 

Then you can measure like
This Period = CALCULATE([% Grade A ], FILTER(ALL('Period'),'Period'[Period Rank]=max('Period'[Period Rank])))
Last Period = CALCULATE([% Grade A ], FILTER(ALL('Period'),'Period'[Period Rank]=max('Period'[Period Rank])-1))

 

Last 13 Period = CALCULATE([% Grade A ], FILTER(ALL('Period'),'Period'[Period Rank]>=max('Period'[Period Rank])-13 && 'Period'[Period Rank]<=max('Period'[Period Rank])))

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

Hello,

What does it mean -> ASC,Dense?

Thanks

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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.