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
gr84
Frequent Visitor

Calculate variance from previous date

Hi,

how is possible to calculate in another column the variance of count from previus date?

My purpose is in case of variace positive start an alert by a query with power automate.

 

gr84_0-1706604076472.png

Thanks

1 ACCEPTED SOLUTION
v-yaningy-msft
Community Support
Community Support

Hi, @gr84 

 

Based on your description, If you have a date column, you can create following new columns to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1706682327947.png

New columns:

Previous Count =

CALCULATE (

    MAX ( 'Table'[Value] ),

    FILTER ( 'Table', 'Table'[Date] = EARLIER ( 'Table'[Date] ) - 1 )

)

 

Variance =

IF (

    'Table'[Date] = MIN ( 'Table'[Date] ),

    BLANK (),

    'Table'[Value] - 'Table'[Previous Count]

)

 

 

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

 

View solution in original post

5 REPLIES 5
v-yaningy-msft
Community Support
Community Support

Hi, @gr84 

 

Based on your description, If you have a date column, you can create following new columns to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1706682327947.png

New columns:

Previous Count =

CALCULATE (

    MAX ( 'Table'[Value] ),

    FILTER ( 'Table', 'Table'[Date] = EARLIER ( 'Table'[Date] ) - 1 )

)

 

Variance =

IF (

    'Table'[Date] = MIN ( 'Table'[Date] ),

    BLANK (),

    'Table'[Value] - 'Table'[Previous Count]

)

 

 

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

 

Hi @v-yaningy-msft ,

thank you, I've insert your solution in my matrix table but my column "count" is calculate then I haven't the column "count" in my table.
How Can I do?

 

Thanks in advance

gr84
Frequent Visitor

Hi,

last update, if I insert new column "previus count" i don't receive expected output.

 

Previous Count =
CALCULATE (
    MAX ( TLC[Count] ),
    FILTER ( 'TLC', TLC[Time_Issue_agg] = EARLIER ( TLC[Time_Issue_agg] ) - 1 )
)

 

gr84_1-1707313511188.png

 

Daniel29195
Super User
Super User

Hello @gr84

use this measure : 

measure = 

var current_date = max(tbl_name[date_col_table])

var prev_date =  current_date - 1 

current_value = sum(tbl_name[count])

prev_date_value =  calculate ( sum(tbl_name[count]) , tbl_name[date_col_table] = prev_date  ) 

 

var variance =  current_value  - prev_date_value 

return variance

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution !
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

Hi @Daniel29195 ,

i've tested your solution and i don't receive expected output.

 

gr84_0-1707314910266.png

Thanks

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.