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

YTD Average - DAX calculation

Dear all,

I'm trying to calculate the YTD 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/period and then make the average from the beginning of this year until a specified period (ex. P5 - or 31st May).

 

Here some data:

 

yearmonthdayCONFORMITYPeriodFactories
2021413OKP04RCR
2021413OKP04RCR
202156OKP05RDM
202156OKP05RDM
202156OKP05RDM
202156OKP05RDM
202156OKP05RDM
2021416OKP04RCC
2021416OKP04RCC
2021418OKP04RCC
2021418OKP04RCC
202153OKP05RCC
202154OKP05RCC
202141OKP04RGU
202141OKP04RGU
202141OKP04RGU
202141OKP04RGU
202141CTRL_NOKP04RGU
202141OKP04RGU
2021412WRNG_NOKP04RGU
2021412WRNG_NOKP04RGU
2021412OKP04RGU
2021412OKP04RGU
2021412OKP04RGU
2021412OKP04RGU
2021429OKP05RGU
2021429OKP05RGU
2021429OKP05RGU
2021429OKP05RGU
2021429OKP05RGU
2021514OKP05RGU
2021514WRNG_NOKP05RGU
2021514OKP05RGU
2021514OKP05RGU
2021514OKP05RGU
2021514OKP05RGU
2021514OKP05RGU
2021514OKP05RGU
2021514OKP05RGU
2021514OKP05RGU
2021514WRNG_NOKP05RGU
2021514OKP05RGU
2021514OKP05RGU

 

I would really appreciate your help.

Best regards

Hervé

 

PS: @v-kelly-msft 

2 ACCEPTED SOLUTIONS

@Anonymous 

pls try this

Measure = DIVIDE(CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[CONFORMITY]="OK")),COUNTROWS('Table'))

1.PNG





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

Proud to be a Super User!




View solution in original post

@Anonymous 

pls change year to rclms_qa[year]





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

Proud to be a Super User!




View solution in original post

17 REPLIES 17
Syndicate_Admin
Administrator
Administrator

Good morning, I press my name is pablo and I am from Argentina and I have a problem to get the average talk time of a telephone exchange, AHT calls, if I on the excel calculate with the average function that value gives me correctly but on power bi I do not find the turn, what I do is calculate the total time of conversation but I do not find the way to get that average, I attach a capture of what I have and if anyone can help me thank you very much.-

pablo4676_0-1662637085867.png

Best regards;

Pablo

@Syndicate_Admin 

pls see the attachment below





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

Proud to be a Super User!




ryan_mayu
Super User
Super User

@Anonymous 

could you pls provide the expected output?





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

Proud to be a Super User!




Anonymous
Not applicable

Hello,

Expected output is the average of Grade A (Conforme products) / period. (ex. YTD -> From P1 (beginning of the year) until P4 (or now), the average of grade A from P1 to P4 (or now)).

Hope I'm clear

Thanks

Hervé

@Anonymous 

could you pls provide the real output based on the sample data you provided? It will be better if you can provide the calculation logic as well.





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

Proud to be a Super User!




Anonymous
Not applicable

Answer should be 88,37 % (average of grade A from P4 & P5).

(Total count OK/(OK + Warning + Non OK)*100

@Anonymous 

pls try this

Measure = DIVIDE(CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[CONFORMITY]="OK")),COUNTROWS('Table'))

1.PNG





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

Proud to be a Super User!




Anonymous
Not applicable

Thanks a lot for you help. Can we specify in this formula, that I would need the % for this year (2021)?

Then I can make the same calculation for 2020 (it will be my objective) and build a KPI.

Best regards

Hervé

@Anonymous 

you can try this and change 2021 to 2020 to get 2020KPI

Measure = DIVIDE(CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[CONFORMITY]="OK"&year=2021)),CALCULATE(COUNTROWS('Table'),FILTER('Table',year=2021)





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

Proud to be a Super User!




Anonymous
Not applicable

Hello

Thanks for your reply.

I tried the formula but I have an error:

 

HerveRC_2020_0-1624005419818.png

 

Do you know why?

Thanks

Hervé

@Anonymous 

sry i missed on & symbol, && is AND function

Measure = DIVIDE(CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[CONFORMITY]="OK"&&year=2021)),CALCULATE(COUNTROWS('Table'),FILTER('Table',year=2021)





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

Proud to be a Super User!




Anonymous
Not applicable

Hello

Sorry - still a mistake:

HerveRC_2020_0-1624006303620.png

Thx

Hervé

 

@Anonymous 

is year your column name? based on your sample data, year column is your first column .pls change to your real column name.





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

Proud to be a Super User!




Anonymous
Not applicable

Strange - yes, my column name is "year"

HerveRC_2020_0-1624007250843.png

 

@Anonymous 

pls change year to rclms_qa[year]





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

Proud to be a Super User!




Anonymous
Not applicable

And I have another question to complexify a bit.

Can you the created 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 add some DAX elements to get the results of my last 13 periods?
Thanks
Hervé
Anonymous
Not applicable

Thanks a lot for your help - it works

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.