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

Decrease/Increase between last 2 days of a visual

Hi Community,

 

I have a challenge in calculating a difference between last 2 days in the below shown table ( 8/4/2021 and 8/5/2021) . Once the difference is calculated , I have to show either an Up arrow or Down arrow to represent  Increase or decrease . 

 

 

Diff btwn last 2 days.JPG

 

Output I want : 

 

output.JPG

 

Thanks,

G venkatesh 

 

 

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

Hi, @Anonymous ;

You could create a measure as follows:

Measure = var _max=MAX([Date])
var _last=CALCULATE(SUM([Value]),FILTER(ALLEXCEPT('Table','Table'[Jobname]),[Date]=_max))
var _pre=CALCULATE(SUM([Value]),FILTER(ALLEXCEPT('Table','Table'[Jobname]),[Date]=_max-1))
return IF(ISINSCOPE('Table'[Date]),SUM([Value]),_last-_pre)

Then add conditional formatting.

vyalanwumsft_0-1628648845822.pngvyalanwumsft_1-1628648861299.png

The final output is shown below:

vyalanwumsft_2-1628648894809.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

@v-yalanwu-msft , @selimovd   and @amitchandak  ,

 

Sorry for late in getting back to all of you, 

 

I liked all of your solutions and everyone of your ideas  is unique of itself. Thanks for helping me out . 

 

@amitchandak  Thanks for your detail explanation and for covering each aspect. 

@selimovd   🙂 Thanks for your idea . Really liked the simple way of projecting it . 

@v-yalanwu-msft  Your idea of using Variables have made me think of learning more about variables a lot. I heard from Marco and Alberto explaining the significance of using variables . you have provided me a solution related to a different issue and that was solved using variables again . 🙂 

 

Thanks,

G Venkatesh 

v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a measure as follows:

Measure = var _max=MAX([Date])
var _last=CALCULATE(SUM([Value]),FILTER(ALLEXCEPT('Table','Table'[Jobname]),[Date]=_max))
var _pre=CALCULATE(SUM([Value]),FILTER(ALLEXCEPT('Table','Table'[Jobname]),[Date]=_max-1))
return IF(ISINSCOPE('Table'[Date]),SUM([Value]),_last-_pre)

Then add conditional formatting.

vyalanwumsft_0-1628648845822.pngvyalanwumsft_1-1628648861299.png

The final output is shown below:

vyalanwumsft_2-1628648894809.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

selimovd
Super User
Super User

Hey @Anonymous ,

 

you can get the difference like this:

Difference to yesterday =
[myMeasure]
    - CALCULATE(
        [myMeasure],
        DATEADD(
            dateTable[date],
            -1,
            DAY
        )
    )

 

 

For the arrows you just have to compare if the value is bigger than 0 or smaller:

Conditional Formatting Using Icons In Power BI - Excelerator BI

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

amitchandak
Super User
Super User

@Anonymous , You have to create day on Day diff measure, for example using a date table 

 

This Day = CALCULATE(sum("order"[Qty]), FILTER(ALL("Date"),"Date"[Date]=max("Date"[Date])))
Last Day = CALCULATE(sum("order"[Qty]), FILTER(ALL("Date"),"Date"[Date]=max("Date"[Date])-1))
Last Day = CALCULATE(sum("order"[Qty]), previousday("Date"[Date]))

 

diff =[This Day] - [Last Day]

 

One of the ways is to show diff in column total using isinscope and do icon conditional formatting only on total

if(isinscope(Date[Date]),[This Day], [diff])

 

refer if needed

https://exceleratorbi.com.au/conditional-formatting-using-icons-in-power-bi/
https://community.powerbi.com/t5/Desktop/FORMAT-icon-set-for-use-in-a-data-card/td-p/811692

 

Or create a hybrid table


if you are looking for a Hybrid display with Matrix Column and measure
https://community.powerbi.com/t5/Community-Blog/Creating-a-custom-or-hybrid-matrix-in-PowerBI/ba-p/1354591
https://community.powerbi.com/t5/Quick-Measures-Gallery/The-New-Hotness-Custom-Matrix-Hierarchy/m-p/963588#M428

vote for Hybrid Table
https://ideas.powerbi.com/ideas/idea/?ideaid=9bc32b23-1eb1-4e74-8b34-349887b37ebc

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.