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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Ajinkya369
Resolver III
Resolver III

Dax measure to display monthly values?

Hi folks,

The file attached contains data collected Quarter to Date, in other words:

Pbix file: QTD to Monthly Data.pbix - Google Drive 

  1. the value for January are the sales for January
  2. the value for February are the sales for January + February
  3. the value for March are the sales for January + February + March
  4. the value for April are for April
  5. And so on.....

Thanks

Ajinkya

1 ACCEPTED SOLUTION

@Ajinkya369 , you might want to try this measure to get a different total,

 

Monthly Data = 
SUMX (
    DISTINCT ( 'QTD Data'[Month] ),
    VAR __current_month = CALCULATE ( MAX ( 'QTD Data'[Month] ) )
    VAR __current_sales = CALCULATE ( SUM ( 'QTD Data'[QTD Sales] ) )
    RETURN
        IF (
            MOD ( MONTH ( __current_month ) , 3 ) = 1,
            __current_sales,
            VAR __prev_month =
                MAXX (
                    FILTER ( ALL ( 'QTD Data'[Month] ), 'QTD Data'[Month] < __current_month ),
                    'QTD Data'[Month]
                )
            RETURN
                __current_sales
                    - CALCULATE ( SUM ( 'QTD Data'[QTD Sales] ), 'QTD Data'[Month] = __prev_month )
        )
)

 

 

 

Screenshot 2020-11-22 204436.png

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

5 REPLIES 5
Ajinkya369
Resolver III
Resolver III

Hey @CNENFRNL ,

First of all thanks for replying, I calculated the total for monthly data in excel where the total is : 295990 and I see

that it is not matching with the total of PBI matrix. Could you please help me further..

 

.Excel TotalExcel TotalPBI Matrix TotalPBI Matrix Total

 

@Ajinkya369 , you might want to try this measure to get a different total,

 

Monthly Data = 
SUMX (
    DISTINCT ( 'QTD Data'[Month] ),
    VAR __current_month = CALCULATE ( MAX ( 'QTD Data'[Month] ) )
    VAR __current_sales = CALCULATE ( SUM ( 'QTD Data'[QTD Sales] ) )
    RETURN
        IF (
            MOD ( MONTH ( __current_month ) , 3 ) = 1,
            __current_sales,
            VAR __prev_month =
                MAXX (
                    FILTER ( ALL ( 'QTD Data'[Month] ), 'QTD Data'[Month] < __current_month ),
                    'QTD Data'[Month]
                )
            RETURN
                __current_sales
                    - CALCULATE ( SUM ( 'QTD Data'[QTD Sales] ), 'QTD Data'[Month] = __prev_month )
        )
)

 

 

 

Screenshot 2020-11-22 204436.png

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

CNENFRNL
Community Champion
Community Champion

Hi, @Ajinkya369 

As the date column consists of incontiguous dates, time intelligence functions, such as DATEADD, ENDOFMONTH etc, don't apply; thus the measure is verbose and fairly complicated. Here's a solution with your original dataset. I attached a pbix file for reference.

Monthly Data = 
VAR __current_sales = SUM ( 'QTD Data'[QTD Sales] )
RETURN
    IF (
        MOD ( MONTH ( MAX ( 'QTD Data'[Month] ) ), 3 ) = 1,
        __current_sales,
        VAR __current = MAX ( 'QTD Data'[Month] )
        VAR __prev =
            MAXX (
                FILTER ( ALL ( 'QTD Data'[Month] ), 'QTD Data'[Month] < __current ),
                'QTD Data'[Month]
            )
        RETURN
            __current_sales
                - CALCULATE ( SUM ( 'QTD Data'[QTD Sales] ), 'QTD Data'[Month] = __prev )
    )

 Without date tableWithout date table


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Nathaniel_C
Community Champion
Community Champion

Hello @Ajinkya369 ,
Not sure what you are trying to do here.  If you have a calendar in your pbix, then you can use Time Intelligence functions such as TOTALQTD() such as TOTALQTD(SUM(InternetSales_USD[SalesAmount_USD]),DateTime[DateKey])

 

https://docs.microsoft.com/en-us/dax/totalqtd-function-dax

 

Let me know if this solves your issue,

 


If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors