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
Anonymous
Not applicable

Dynamic selection of datesand calculations

Hi All, 

 

Need help on thebelow scenario.

 

If the data has a dates  (Data attached) and the financial year starts from Apr. Has two filters in the report Financial Year and Date and total sales. need help to calcualte sum of sales based on month selection. 

 

Example: If selected Jun'21 in month filter, should able to calcualte sales for the months of Apr'21 to Jun'21

Exp2: If selected Mar'21 in month filter, should able to calcualte sales for the months of Jan'21 to Mar'21

 

based on the month selection it should dynamically pick the durationand calcualte the sales figures.

https://drive.google.com/file/d/1bT9g09dzbd70cGDQXXOZnk5r1MJ-9EWQ/view?usp=sharing 

Please let me know if you need further information

 

Regards

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

Hi, @Anonymous 

 

You can easily create a measure to diaplay the result.

Like this:

Measure = 
VAR a =
    DATEADD ( 'Table'[Date], -1, QUARTER )
RETURN
    CALCULATE ( SUM ( Sheet1[sales] ), FILTER ( ALL ( 'Table' ), [Date] IN a ) 

v-janeyg-msft_0-1619780884783.png

Best Regards

Janey Guo

 

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

2 REPLIES 2
v-janeyg-msft
Community Support
Community Support

Hi, @Anonymous 

 

You can easily create a measure to diaplay the result.

Like this:

Measure = 
VAR a =
    DATEADD ( 'Table'[Date], -1, QUARTER )
RETURN
    CALCULATE ( SUM ( Sheet1[sales] ), FILTER ( ALL ( 'Table' ), [Date] IN a ) 

v-janeyg-msft_0-1619780884783.png

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , this seems like you need QTR till date?  that you can do with a date table

 

example

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))
Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))

 

 

YTD based on 3/31 year end date

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"3/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"3/31"))

 

Power BI — Qtr on Qtr with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839
https://www.youtube.com/watch?v=8-TlVx7P0A0

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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