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
kan
Helper I
Helper I

dax to calculate from first day of year to end of each Quarter

Hi,

     in power bi desktop I have

               1)following dataset which is calculating amount for each quarter means from January to March,April to June,July to September and October to December.

 

select datepart(QUARTER, entrydate_inrevenue) revenuequarter
,sum(amount)Amount
from Accounts
where
datepart(year, entrydate_inrevenue) = datepart(year,getdate())
group by datepart(QUARTER, entrydate_inrevenue)

 

But For my report I need to calculate cumulative values from january to March,January to June,January to September,January to December.which means from starting of year to end of each quarter.

 

I also have dimdate table in my database.

 

 

Can someone please explain how to implement this.

 

Thanks.

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

hi, @kan

After my research, you could try this way as below:

Add a Quarter NO column for date table

Quarter NO = INT ( FORMAT ( [Date], "q"))

17.JPG

Step2:

Add a measure by this formula

result = 
CALCULATE (
    SUM ( 'Table'[Amount] ),
    FILTER (
        ALL ( 'Date' ),
        AND (
            'Date'[Quarter NO] <= MAX ( 'Date'[Quarter NO] ),
            YEAR ( 'Date'[Date] ) = YEAR ( TODAY () )
        )
    )
)

Result:

18.JPG

 

here is pbix, please try it.

https://www.dropbox.com/s/2lhx9l50z8q0xt7/dax%20to%20calculate%20from%20first%20day%20of%20year%20to...

 

Best Regards,

Lin

 

 

 

Community Support Team _ Lin
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

1 REPLY 1
v-lili6-msft
Community Support
Community Support

hi, @kan

After my research, you could try this way as below:

Add a Quarter NO column for date table

Quarter NO = INT ( FORMAT ( [Date], "q"))

17.JPG

Step2:

Add a measure by this formula

result = 
CALCULATE (
    SUM ( 'Table'[Amount] ),
    FILTER (
        ALL ( 'Date' ),
        AND (
            'Date'[Quarter NO] <= MAX ( 'Date'[Quarter NO] ),
            YEAR ( 'Date'[Date] ) = YEAR ( TODAY () )
        )
    )
)

Result:

18.JPG

 

here is pbix, please try it.

https://www.dropbox.com/s/2lhx9l50z8q0xt7/dax%20to%20calculate%20from%20first%20day%20of%20year%20to...

 

Best Regards,

Lin

 

 

 

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

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.