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
Anonymous
Not applicable

Operation on matching rows

Hello everyone,

 

I have the following data table:

FinYui8_0-1653379150903.png

 

And I need to be able to do the following operation: When the Date, Cat2 and Cat3 columns match, they multiply the Value column by their match column, i.e. in the example case you would do the following:

FinYui8_1-1653379181867.png

 

 

Finally, the result should be added, obtaining the following:

 

30+24+30+35 = 119

 

Does anyone know how to do it without having to create a new table?

 

Thank you very much!

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@Anonymous 

 

Measure = 
    SUMX(
        SUMMARIZE(
            'Table',
            'Table'[Date],
            'Table'[Cat2],
            'Table'[Cat3]
        ),
        CALCULATE(
            PRODUCTX(
                    'Table',
                    [Value]
            )
        )
    )

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

4 REPLIES 4
rohit_singh
Solution Sage
Solution Sage

Hi @Anonymous ,

1) Load your data into report view

rohit_singh_0-1653380665489.png

 

2) Add a calculated column to fetch previous value

 

rohit_singh_1-1653380765293.png

 

Prev Value =

CALCULATE(
MAX(Categories[Value]),
FILTER(Categories,
Categories[Cat2] = EARLIER(Categories[Cat2]) &&
Categories[Cat3] = EARLIER(Categories[Cat3]) &&
Categories[Value] < EARLIER(Categories[Value])
)
)
 
3) Add another calculated column to multily value and previous value
 
rohit_singh_2-1653380865877.png
Multiplied value = Categories[Prev Value] * Categories[Value]
 
4) You can now sum the multiplied value column to get the desired result.
 

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 😊

SpartaBI
Community Champion
Community Champion

@Anonymous 

 

Measure = 
    SUMX(
        SUMMARIZE(
            'Table',
            'Table'[Date],
            'Table'[Cat2],
            'Table'[Cat3]
        ),
        CALCULATE(
            PRODUCTX(
                    'Table',
                    [Value]
            )
        )
    )

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Anonymous
Not applicable

Thanks a lot!

@Anonymous my pleasure 🙂
Hey, check out my showcase report:
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543
Give it a thumbs up if you liked it 🙂

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.