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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ZaheenHamidani
Frequent Visitor

How to have the total of only the current products?

ZaheenHamidani_0-1616962046732.png

 

I am trying to get the participation of the current date products within the total amount of three months ago. The sum of these is correct (604040) but I want the actual products total (273158).

 

I hope you could help with this.

 

Thanks.

 

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @ZaheenHamidani 

 

You may try the following measure to see if it works.

x =
VAR tab =
    SUMMARIZE (
        BD,
        BD[MARCA],
        BD[ARTICULO],
        "Result",
            VAR MAXDATE =
                MAX ( BD[FECHA] )
            VAR EndYear =
                YEAR ( LASTDATE ( BD[FECHA] ) )
            VAR EndMonth =
                MONTH ( LASTDATE ( BD[FECHA] ) )
            VAR Monto =
                CALCULATE (
                    SUM ( BD[MONTO] ),
                    FILTER ( BD, YEAR ( BD[FECHA] ) = EndYear && MONTH ( BD[FECHA] ) = EndMonth )
                )
            VAR TRESTABLE =
                CALCULATETABLE (
                    BD,
                    DATESINPERIOD ( BD[FECHA], EOMONTH ( MAXDATE, -1 ), -3, MONTH )
                )
            RETURN
                SUMX ( TRESTABLE, IF ( ISBLANK ( Monto ), BLANK (), BD[MONTO] ) )
    )
RETURN
    SUMX ( tab, [Result] )

 

Best Regards

Allan

 

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

AllisonKennedy
Super User
Super User

@ZaheenHamidani  I don't see the 273158 in your screenshot - what is 'actual products' mean? Can you please define this?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

ZaheenHamidani_0-1616969976556.png

 

If I download the table it will give the sum 273158 and 45.22%. When I say "actual products" I mean the products that I sold the filtered month.

 

January:

A21: 13

A24: 15

A27: 10

 

February: 

B15: 45

B13: 56

A21: 34

 

March

A37: 34

A23: 45

B12: 34

C11: 45

 

April:

A23: 45

B12: 34

B15: 56

A24: 23

A21: 34

 

I need the three months before April to sum but let just the products that are in April:

A23: 45

B12: 34

B15: 45

A24: 15

A21: (34+13) = 47

Hi,

Your question is still not clear.  Share the link from where i can download your PBI file and show the expected result there clearly.  Please also ensure that the language in the PBI file is Engligh or else please clealry let me know the transaltion of the relevant columns.


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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.