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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
FMF
Frequent Visitor

Calculate KPI Average value and Count number of times KPI exceeded Threshold

Hi 

 

I want to achieve the below with DAX commands

 

1) Avg Value: Display the Average value of KPI IDx (x = 1, 2 ... N) from Table 1 based on a KPI selected @ run time. The User selected KPI @ run time will be based on KPI Name field from Table 3 and it has to be selected from a slicer. It has be a dynamic dax calculation, considering the fact that there are huge number of KPI columns and the list in Table 3 can grow

2) Count Value: Count the number of times KPI IDx (x = 1, 2 ... N) from Table 1 is above or below a user defined threshold. The user defined threshold will be based on Threshold field from Table 3 and the above or below condition will be based on the Sign field from Table 3

 

Table 1 & Table 2 are linked in the Model based on Joiner Field. the Joiner field is uinque in Table 1

 

Table 1

Joiner FieldAttribute 1Attribute 2….Attribute n
A    
B    
C    
D    
     
     

 

Table 2

Joiner FieldDateKPI ID 1KPI ID 2….KPI ID n
A01.01.202098 0.3  
A02.01.202095 0.7  
A03.01.202093 0.8  
B01.01.202092 0.2  
B02.01.202092 0.1  
B03.01.202091 0.1  
C01.01.202098 0.9  
C02.01.202099 1.5  
C03.01.202098 1.2  
..     
..     

 

Table 3

KPI IDKPI NameThresholdSign
KPI 1xxxxx95<
KPI 2yyyyy0.5>
...   
KPI nzzzzz98<

 

Ouput Examples

User Selected KPI Name = xxxx 

Joiner Field (Table 1)Attribute 1 Attribute 2….Attribute nKPI (Avg Value) KPI (Count) 
A    95.332
B    91.663
C    98.330
D      
       

 

User Selected KPI Name = yyyy 

Joiner Field (Table 1)Attribute 1Attribute 2….Attribute nKPI (Avg Value) KPI (Count) 
A    0.62
B    0.130
C    1.23
D      
       

 

Floyd

1 REPLY 1
kentyler
Solution Sage
Solution Sage

I'm not certain how your KPI's are calculated. I am pretty sure you will have to unpivot your data, like this Joiner FieldDateAttributeValue

A 1/1/2020 KPI ID 1 98
A 1/1/2020 KPI ID 2 0.3
A 2/1/2020 KPI ID 1 95
A 2/1/2020 KPI ID 2 0.7
A 3/1/2020 KPI ID 1 93
A 3/1/2020 KPI ID 2 0.8
B 1/1/2020 KPI ID 1 92
B 1/1/2020 KPI ID 2 0.2
B 2/1/2020 KPI ID 1 92
B 2/1/2020 KPI ID 2 0.1
B 3/1/2020 KPI ID 1 91
B 3/1/2020 KPI ID 2 0.1
C 1/1/2020 KPI ID 1 98
C 1/1/2020 KPI ID 2 0.9
C 2/1/2020 KPI ID 1 99
C 2/1/2020 KPI ID 2 1.5
C 3/1/2020 KPI ID 1 98
C 3/1/2020 KPI ID 2 1.2

to avoid overly complex dax calculations





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors
Top Kudoed Authors