Sreedhar
Sreedhar

Reputation: 30045

DAX - Time Intelligence - Year to Quarter

My Dataset

enter image description here

am trying create a report based on the selected quarter

What I want is sum of sales by quarter grouped by product in one column and sum of sales for the year until selected quarter for that year.

Example: (this is what i got ... not right though) enter image description here

Model:

enter image description here

DAX:

ByProductforselectedquarter = 
VAR vTable =
    SUMMARIZE ( 
        sales,
        
        Sales[Product], Sales[Sales] )
VAR Result =
    SUMX ( vTable, Sales[Sales] )
RETURN
    Result

how to get sales for the year until selected quarter for that year.

Upvotes: 0

Views: 54

Answers (1)

mkRabbani
mkRabbani

Reputation: 16918

You can try something as below-

ByProductUptoselectedquarter =

var selected_max_date = max(Date[Date])
var selected_year = Year(selected_max_date)

return 
calculate(
    sum(Sales[Sales]),
    filter(
        all(Sales),
        Year(Sales[Date]) = selected_year
            && Sales[Date] <= selected_max_date 
    )
)

Upvotes: 2

Related Questions