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

How do I count the result of a measure?

Hi everyone!

So I have created some measures to calculate the difference between some values in two different time stamps. Having the measure that calculates that difference,  I would also like to have a measure that counts all the possitive values outputed from that measure. I have tried some stuff out but with no luck. Below I show the measures I've used. Any help would be much appreciated. Let me know if you need any more information.

After Avg KPI Value = 
CALCULATE(
    AVERAGE('DVI KPI'[KPI value]);
    FILTER(
        'DVI KPI';
        [Snapshot ID] = MAX('Snapshot Date Info'[Snapshot ID])
    )
)

Before Avg KPI Value = 
CALCULATE(
    AVERAGE('DVI KPI'[KPI value]);
    FILTER(
        'DVI KPI';
        [Snapshot ID] = MIN('Snapshot Date Info'[Snapshot ID])
    )
)

// I want to count the output of this measure
PBDC Avg KPI Value = 
    var __Difference = [Before Avg KPI Value] - [After Avg KPI Value]
return
    DIVIDE(__Difference; [Before Avg KPI Value])

 

10 REPLIES 10
Anonymous
Not applicable

Hi @Mariusz @rajulshah 
I can share just those screenshots just so you can have an idea of the data I'm using.

NikBat2020_0-1594365724174.pngNikBat2020_1-1594365930676.png

NikBat2020_2-1594365958857.png

 

 

Hi @Anonymous ,

 

Just a guess, in the same context for your [After Avg KPI Value]  and [Before Avg KPI Value]  MAX('Snapshot Date Info'[Snapshot ID]) = MIN('Snapshot Date Info'[Snapshot ID]).

 

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

 

Best Regards,

Dedmon Dai

 

 

 

rajulshah
Super User
Super User

Hello @Anonymous,

 

You can create another measure:

Total KPI Value =
VAR SummarizedTable =
    SUMMARIZE (
        'Snapshot Date Info',
        'Snapshot Date Info'[Snapshot ID],
        "AvgKPIValue", [After Avg KPI Value]
    )
RETURN
    COUNTX ( FILTER ( SummarizedTable, [AvgKPIValue] > 0 ), [Snapshot ID] )

Hope this helps. Let me know if it doesn't.

Anonymous
Not applicable

Hi @rajulshah 

No luck unfortunately. Here's what I got. I made some changes to your formula, like the measure I want to count and the Table that has the actual KPI values I am using in the previous measures

res 1.png

Hello @Anonymous ,

 

Can you provide sample file?

Anonymous
Not applicable

Hi @rajulshah 

Im sorry I can't. The file contains a lot of sensitive information and I've been told I can't share it. 

Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

You will need to first define the grain, let's say your visual has Date and colour columns, your measure would be.

PBDC Avg KPI Value =   
SUMX(
    SUMMARIZE( 'DVI KPI', 'DVI KPI'[date], 'DVI KPI'[Colour] ),
    VAR __Difference = 
        [Before Avg KPI Value] - [After Avg KPI Value]
    RETURN 
        INT( 
            DIVIDE( __Difference; [Before Avg KPI Value] ) > 1
        )
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Anonymous
Not applicable

Hi @Mariusz 
I tried the measure and it didn't quite work for now. Here's what I got

 

res 2.png

Hi @Anonymous 

 

Try using 

 

VALUES( 'DVI KPI'[Snapshot ID] )

 

instead of SUMMARIZE() 

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn


 

Anonymous
Not applicable

@Mariusz Do you mean like that?

 

 

NikBat2020_0-1594365365648.png

 

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.