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
AishwariyaV
Helper IV
Helper IV

Dax correction

Hi,

Measure = CALCULATE(SUM(SalesOrderDetails[Sales]),FILTER(SalesOrderDetails,
YEAR(SalesOrderDetails[DGIDate]) = YEAR(SalesOrderDetails[Current date]) &&
QUARTER(SalesOrderDetails[DGIDate]) = QUARTER(SalesOrderDetails[Current date]) &&
YEAR(SalesOrderDetails[FRGIDate]) = PREVIOUSYEAR(SalesOrderDetails[Current date]) &&
QUARTER(SalesOrderDetails[FRGIDate]) = PREVIOUSQUARTER(SalesOrderDetails[Current date])))
 
I am not sure what is wrong with this measure. It doesn't work when a category is selected.
My guess is it might be due to PREVIOUSYEAR and PREVIOUSQUARTER dax functions.
Can anyone help?
1 ACCEPTED SOLUTION

V-lianl-msft_0-1617778897613.png

According to the data you provided, the result should be 80.

Measure = CALCULATE(
    SUM('Table'[Sales]),
    FILTER('Table',
        'Table'[FRGI date]<'Table'[DGI date]&&
        'Table'[FRGI date]>=DATEADD('Table'[DGI date].[Date],-1,QUARTER)))

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@AishwariyaV , whar are you trying to achieve here ?

 

 

refer these examples

 

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

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

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
next month Sales = CALCULATE(SUM(Sales[Sales Amount]),nextmonth('Date'[Date]))

 

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

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

FRGI date    DGI date   Sales
01/01/2021 01/04/2021 40
16/02/2021 01/04/2021 30
01/04/2021 01/07/2021 10
21/03/2021 12/07/2021 20
11/12/2020 01/04/2021 50


The result should be 40 + 30 = 70.

V-lianl-msft_0-1617778897613.png

According to the data you provided, the result should be 80.

Measure = CALCULATE(
    SUM('Table'[Sales]),
    FILTER('Table',
        'Table'[FRGI date]<'Table'[DGI date]&&
        'Table'[FRGI date]>=DATEADD('Table'[DGI date].[Date],-1,QUARTER)))

Hi @V-lianl-msft ,

The FRGI date should be equal to previous quarter only and not the current quarter. 01/04/2021 (DD-MM-YYYY), falls under current quarter.

Let me give a try with the measure.

 

Thanks 😊

I want the sum of sales with filter as, 

FRGI Year = Year which falls in the previous quarter from current date

FRGI Quarter = Previous quarter from the current date

DGI year = current year from current date

DGI quarter = current quarter from current date

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.