Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Saabr
Frequent Visitor

Line graph for date selected in slicer and the date right before it

Hi! I'm rather new to Power BI and I'm not sure if this has been asked before. I looked in the forums and googled but I can't seem to find exactly what I need. I would be very grateful to anyone for any light shed on this.

 

My objective? To show the values (per hour) of the date selected on the slicer as well as the values (also per hour) of the date right before the date selected on the slicer.

 

So say given a sample dataset of random sales values:

HourDateSales
18/8/2019221
28/8/2019293
38/8/2019524
48/8/2019742
18/9/2019455
28/9/2019505
38/9/2019451
48/9/2019484
18/10/2019121
28/10/2019780
38/10/2019131
48/10/2019722
208/12/2019761
218/12/2019396
228/12/2019970
238/12/2019285
248/12/2019157

 

If I choose the date of 11-Aug-2019 on my slicer, it should present the data of both, like so:

 

SLICER.PNG

SAMPLE.PNG

With 8-Aug-2019 not having to be selected in the slicer.

 

I've tried several things, I've made measures where I've made the dates into an integer and made it so that when I choose the date on the slicer, it gives the selected date - 1. 

 

Date selected and Date before.PNG

Formulae are as follows:

Day before = calculate([Selected Date]-1)
Selected Date = int(SELECTEDVALUE('kit-db'[Date]))
 

I've also made sales values connected to these measures of day before and selected date:

 

YTD GMV = sumx(filter('sales table,'sales table'[date order created].[Year]=Year(Now())), 'sales table'[sales])
GMV Day Before = CALCULATE( [YTD GMV], FILTER('sales table',int('sales table'[date order created])= [Day before]))
 
So when I do choose a date in the slicer, it would give me the 'slice' of the data that under the date chosen, and since it has already sliced that data there, I can't get the other part of the data beside it.
 
Do you guys have any thoughts? Any suggestions would be most appreciated. Thank you!
 
 

 

 

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Saabr 

 

If you are looking to compare current vs previous days sales, you can use two measures below.

Sales Measure = SUM( 'Table'[Sales] )
Sales ( previous Day ) Measure = 
CALCULATE(
    SUM( 'Table'[Sales] ),
    PREVIOUSDAY( 'Table'[Date] )
)

This will give you the below result based on the provided dataset 

image.png

 

Best Regards,
Mariusz

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

Please feel free to connect with me.
Mariusz Repczynski

 

View solution in original post

3 REPLIES 3
Mariusz
Community Champion
Community Champion

Hi @Saabr 

 

If you are looking to compare current vs previous days sales, you can use two measures below.

Sales Measure = SUM( 'Table'[Sales] )
Sales ( previous Day ) Measure = 
CALCULATE(
    SUM( 'Table'[Sales] ),
    PREVIOUSDAY( 'Table'[Date] )
)

This will give you the below result based on the provided dataset 

image.png

 

Best Regards,
Mariusz

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

Please feel free to connect with me.
Mariusz Repczynski

 

Saabr
Frequent Visitor

Much Thank! I didn't know there was a prev function! Thank you!

Mariusz
Community Champion
Community Champion

Hi @Saabr 

 

Are you looking to compare the current date to the previous one?
Also, what would you like to do with the 11th of Aug as it is not in your dataset?

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski


 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.