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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
SJAV
Frequent Visitor

Sum an existing measure in matrix per row

Hi!

 

I'm been dealing with an issue for a while that I am not able to solve. I have a matrix with 1 row, 1 column and 1 Value (the value is a measure) like below (image1). What I am trying to do is add an additional measure that basically checks if any value in the row has 1. If so, then I want to whole row to get the value 1 (see image 2). I've been looking into MAXX and SUMX but it is not working. Are there any other solution I can look into?

 

image1

 USACANMEX
A101
B000
C011

 

image2

 USACANMEX
A111
B000
C111
1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @SJAV 

Thanks for your sample data and detailed description.

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1689212781897.png

(2)I create a measure to simulate your situation:

Measure = SUM('Table'[Value])
vyueyunzhmsft_1-1689212823158.png

(3)Then we can create the measure like this:

Measure 2 = var _t =ADDCOLUMNS( CROSSJOIN( VALUES('Table'[Row]) , ALLSELECTED('Table'[Column])) , "m" , [Measure])
return
IF(SUMX(_t,[m])>0,1,0)

 

Then we can put this measure on the visual and we can get the result as follows:

vyueyunzhmsft_2-1689212858953.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

View solution in original post

3 REPLIES 3
v-yueyunzh-msft
Community Support
Community Support

Hi , @SJAV 

Thanks for your sample data and detailed description.

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1689212781897.png

(2)I create a measure to simulate your situation:

Measure = SUM('Table'[Value])
vyueyunzhmsft_1-1689212823158.png

(3)Then we can create the measure like this:

Measure 2 = var _t =ADDCOLUMNS( CROSSJOIN( VALUES('Table'[Row]) , ALLSELECTED('Table'[Column])) , "m" , [Measure])
return
IF(SUMX(_t,[m])>0,1,0)

 

Then we can put this measure on the visual and we can get the result as follows:

vyueyunzhmsft_2-1689212858953.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

Thank you! This worked after a small modification 🙂

Measure 2 = var _t =ADDCOLUMNS( CROSSJOIN( ALLSELECTED('Table'[Row]) , ALLSELECTED('Table'[Column])) , "m" , [Measure])
return
IF(SUMX(_t,[m])>0,1,0)

Sahir_Maharaj
Super User
Super User

Hello @SJAV,

 

Can you please try:

NewMeasure = IF(MAX('YourTable'[Value]) = 1, 1, 0)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 13K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.