cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
FredYeung_856
Helper I
Helper I

5 Consecutive Day-Over-Day Sales Increase

Dear all,

 

I have built a PBI report showing the day-over-day increase (the red triangles) of our stores' sales. Is there any way to highlight those stores with day-over-day increases for 5 consecutive days?

 

FredYeung_856_0-1657009531678.png


Please kindly advise, thanks

 

Fred

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi,

I tried to create a sample pbix file like below.

And because I am using my sample, I tried to create a measure for finding Four-days-consecutive-increase-store.

Please check the below picture and the attached pbix file.

I hope the below can provide some ideas on how to create your own measure for your data model.

 

sample.png

 

Sales measure: = 
SUM( Sales[Sales] )

 

DoD increase: = 
VAR _yesterdaysales =
    CALCULATE ( [Sales measure:], 'Calendar'[Date] = MAX ( 'Calendar'[Date] ) - 1 )
VAR _todaysales = [Sales measure:]
RETURN
    IF ( _todaysales > _yesterdaysales, 0, 1 )

 

Four days increase consecutive: = 
VAR _newtable =
    ADDCOLUMNS (
        SUMMARIZE (
            FILTER ( ALL ( Sales ), Sales[Store] = MAX ( Store[Store] ) ),
            'Calendar'[Date]
        ),
        "@DoD_condition", [DoD increase:]
    )
VAR _addcumulatevalue =
    ADDCOLUMNS (
        _newtable,
        "@cumulate_condition",
            SUMX (
                FILTER ( _newtable, 'Calendar'[Date] <= EARLIER ( 'Calendar'[Date] ) ),
                [@DoD_condition]
            )
    )
VAR _groupbycumulatecondition =
    FILTER (
        GROUPBY (
            _addcumulatevalue,
            [@cumulate_condition],
            "@fourormoreconsecutive", SUMX ( CURRENTGROUP (), 1 )
        ),
        [@fourormoreconsecutive] > 4
    )
VAR _condition =
    COUNTROWS ( _groupbycumulatecondition ) <> BLANK ()
RETURN
    _condition

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

Hi,

Thank you for your feedback.

I am not sure how you want to display, but please check the below picture and the attached file.

 

Untitled.png

 

Sales measure only true: = 
IF ( [Four days increase consecutive:] = TRUE (), [Sales measure:], BLANK () )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

5 REPLIES 5
Jihwan_Kim
Super User
Super User

Hi,

I tried to create a sample pbix file like below.

And because I am using my sample, I tried to create a measure for finding Four-days-consecutive-increase-store.

Please check the below picture and the attached pbix file.

I hope the below can provide some ideas on how to create your own measure for your data model.

 

sample.png

 

Sales measure: = 
SUM( Sales[Sales] )

 

DoD increase: = 
VAR _yesterdaysales =
    CALCULATE ( [Sales measure:], 'Calendar'[Date] = MAX ( 'Calendar'[Date] ) - 1 )
VAR _todaysales = [Sales measure:]
RETURN
    IF ( _todaysales > _yesterdaysales, 0, 1 )

 

Four days increase consecutive: = 
VAR _newtable =
    ADDCOLUMNS (
        SUMMARIZE (
            FILTER ( ALL ( Sales ), Sales[Store] = MAX ( Store[Store] ) ),
            'Calendar'[Date]
        ),
        "@DoD_condition", [DoD increase:]
    )
VAR _addcumulatevalue =
    ADDCOLUMNS (
        _newtable,
        "@cumulate_condition",
            SUMX (
                FILTER ( _newtable, 'Calendar'[Date] <= EARLIER ( 'Calendar'[Date] ) ),
                [@DoD_condition]
            )
    )
VAR _groupbycumulatecondition =
    FILTER (
        GROUPBY (
            _addcumulatevalue,
            [@cumulate_condition],
            "@fourormoreconsecutive", SUMX ( CURRENTGROUP (), 1 )
        ),
        [@fourormoreconsecutive] > 4
    )
VAR _condition =
    COUNTROWS ( _groupbycumulatecondition ) <> BLANK ()
RETURN
    _condition

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thanks Jihwan

 

May I consult with you on how to just display the stores if the four consecutive days condition is "TRUE"?

 

 

Hi,

Thank you for your feedback.

I am not sure how you want to display, but please check the below picture and the attached file.

 

Untitled.png

 

Sales measure only true: = 
IF ( [Four days increase consecutive:] = TRUE (), [Sales measure:], BLANK () )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


amitchandak
Super User
Super User

@FredYeung_856 , Assume you already have DOD measure with help from date table try a measure like

 

Rolling 5 = If( calculate(Sumx(Values('Date'[Date]),if([DOD] >0,1,0)),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-5,day)) = 5, 1, blank())

 

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Thanks  @amitchandak 

 

However, I encounter the following error. Is there anything i did wrong?

 

FredYeung_856_0-1657011782090.png

 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors