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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

How to multiply by grouping rows in dax?

 

I have a dataset grouped by two rows as below

GroupName    Score   Multiply
Group1        2      
Group2        3
Group2        5
Group1        1

I have a slicer based on the parameter table for storing the above GroupName values. so when I select Group1( I am using a selected function on variable in my dax) I want to multiply all rows for Group1(scores) by 4 and all rows for Group2(score) by 6.

I tried this but it is updating all rows.

var a=4*score
var b=6*score
var mm=selectedvalue('Group Paramter'[Group Name])

Return if( mm ="Group1", a, b)

But it multiplies all rows, how can I multiply by grouping using GroupName?

How can I achieve this? I apperciate for any help.

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Please try:

 

measure = 
var SCORE = SUMX('Table','Table'[Score])
return SWITCH(TRUE(),
SELECTEDVALUE('Table'[GroupName])="G1",SCORE*4,
SELECTEDVALUE('Table'[GroupName])="G2",SCORE*6)

Vlianlmsft_0-1624947123216.png

 

View solution in original post

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

Please try:

 

measure = 
var SCORE = SUMX('Table','Table'[Score])
return SWITCH(TRUE(),
SELECTEDVALUE('Table'[GroupName])="G1",SCORE*4,
SELECTEDVALUE('Table'[GroupName])="G2",SCORE*6)

Vlianlmsft_0-1624947123216.png

 

amitchandak
Super User
Super User

@Anonymous , You can nor create a new column based on slicer value , You need to create a measure 

 

measure =var mm= if(selectedvalue('Group Paramter'[Group Name])="Group1", 4,6)
return
sumx(Table, [Score]*mm)

 

or

 

measure  =

 

var mm= if(selectedvalue('Group Paramter'[Group Name])="Group1", 4,6)
return
sum( [Score])*mm)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors