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
kadapavel
Helper II
Helper II

calculate growth of counter

Hello,

please suggest how to calculate growth of the signal.

Capture5.PNG

I tried something like, but seems I do not understand logic well

MCBcounter = 
VAR MCBPreviousDay = 
calculate(
   MIN('[7230004][01][35 05]'[Value])
	RETURN
    '[7230004][01][35 05]'[Value] - MCBPreviousDay

With regards

 

2 ACCEPTED SOLUTIONS
DAX0110
Resolver V
Resolver V

Hi @kadapavel, you're going in the right direction - the signal growth = today's value - previous day's value

 

The previous day's row could be thought of as having the maximum timestamp that's less than today's timestamp.

 

There is probably a more elegant way to express this idea, but this is how I'd do it :

 

Define a calculated column :

 

=VAR thisOrderBy = '[7230004][01][35 05]'[SignalTimestamp]
VAR thisEntity = '[7230004][01][35 05]'[Name]
VAR thisValue = '[7230004][01][35 05]'[Value]
VAR prevValue = CALCULATE( 
	FIRSTNONBLANK('[7230004][01][35 05]'[Value], 0)
	, CALCULATETABLE(
		TOPN( 1 
			, '[7230004][01][35 05]' 
			, '[7230004][01][35 05]'[SignalTimestamp]
			, DESC 
			)
		,  ALL( '[7230004][01][35 05]' )
		, '[7230004][01][35 05]'[Name] = thisEntity
		, '[7230004][01][35 05]'[SignalTimestamp] < thisOrderBy
		)
	)
RETURN
	IF( ISBLANK(prevValue)
		, BLANK()
		,  thisValue - prevValue
	)
	
	

 

 

 

 

View solution in original post

Hi @kadapavel

 

Try this calculated column

 

MCB Counter =
VAR PreviousDate =
    CALCULATE (
        MAX ( TableName[SignalTimeStamp] ),
        FILTER (
            ALL ( TableName ),
            TableName[SignalTimeStamp] < EARLIER ( TableName[SignalTimeStamp] )
        )
    )
RETURN
    TableName[Value]
        - CALCULATE (
            SUM ( TableName[Value] ),
            FILTER ( ALL ( TableName ), TableName[SignalTimeStamp] = PreviousDate )
        )

Regards
Zubair

Please try my custom visuals

View solution in original post

3 REPLIES 3
DAX0110
Resolver V
Resolver V

Hi @kadapavel, you're going in the right direction - the signal growth = today's value - previous day's value

 

The previous day's row could be thought of as having the maximum timestamp that's less than today's timestamp.

 

There is probably a more elegant way to express this idea, but this is how I'd do it :

 

Define a calculated column :

 

=VAR thisOrderBy = '[7230004][01][35 05]'[SignalTimestamp]
VAR thisEntity = '[7230004][01][35 05]'[Name]
VAR thisValue = '[7230004][01][35 05]'[Value]
VAR prevValue = CALCULATE( 
	FIRSTNONBLANK('[7230004][01][35 05]'[Value], 0)
	, CALCULATETABLE(
		TOPN( 1 
			, '[7230004][01][35 05]' 
			, '[7230004][01][35 05]'[SignalTimestamp]
			, DESC 
			)
		,  ALL( '[7230004][01][35 05]' )
		, '[7230004][01][35 05]'[Name] = thisEntity
		, '[7230004][01][35 05]'[SignalTimestamp] < thisOrderBy
		)
	)
RETURN
	IF( ISBLANK(prevValue)
		, BLANK()
		,  thisValue - prevValue
	)
	
	

 

 

 

 

Hi @kadapavel

 

Try this calculated column

 

MCB Counter =
VAR PreviousDate =
    CALCULATE (
        MAX ( TableName[SignalTimeStamp] ),
        FILTER (
            ALL ( TableName ),
            TableName[SignalTimeStamp] < EARLIER ( TableName[SignalTimeStamp] )
        )
    )
RETURN
    TableName[Value]
        - CALCULATE (
            SUM ( TableName[Value] ),
            FILTER ( ALL ( TableName ), TableName[SignalTimeStamp] = PreviousDate )
        )

Regards
Zubair

Please try my custom visuals

Thank you very much!

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.