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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
samerhaidar0811
Frequent Visitor

SUM of metrics selected in parameter

Hi guys,

 

Consider the table below.

dimension1dimension2dimension3      x     y      z
abcgrhjuk231
crfgrgrukr862
rfg5frfrghr5953

 

I created a parameter which you can select one or multiple metrics (x,y,z)

What i want now if to create a measure which would sum up the values you selected in the parameter.- So if i selected x and y, the measure would be sum(x) + sum(y). Is this possible? 

 

Thanks in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @samerhaidar0811 ,

Please try below steps:

1.below is my test table

Table:

vbinbinyumsft_0-1668500781363.png

Table2:

create with dax formula

Table 2 = {"x","y","z"}

vbinbinyumsft_1-1668500812908.png

2. create a measure with below dax formula

Measure =
VAR _str =
    IF ( ISFILTERED ( 'Table 2'[Value] ), CONCATENATEX ( 'Table 2', [Value] ) )
VAR sum_x =
    SUMX ( ALL ( 'Table' ), [x] )
VAR sum_y =
    SUMX ( ALL ( 'Table' ), [y] )
VAR sum_z =
    SUMX ( ALL ( 'Table' ), [z] )
VAR _a =
    SWITCH (
        SELECTEDVALUE ( 'Table 2'[Value] ),
        "x", sum_x,
        "y", sum_y,
        "z", sum_z
    )
VAR _b =
    SWITCH (
        TRUE (),
        CONTAINSSTRING ( _str, "xy" ), sum_x + sum_y,
        CONTAINSSTRING ( _str, "xz" ), sum_x + sum_z,
        CONTAINSSTRING ( _str, "yz" ), sum_y + sum_z
    )
RETURN
    IF (
        LEN ( _str ) = 3,
        sum_x + sum_y + sum_z,
        SWITCH (
            TRUE (),
            HASONEVALUE ( 'Table 2'[Value] ), _a,
            NOT ( HASONEVALUE ( 'Table 2'[Value] ) ), _b
        )
    )

4. add a slicer with Table2 and card visual with measure

Animation15.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
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
Anonymous
Not applicable

Hi @samerhaidar0811 ,

Please try below steps:

1.below is my test table

Table:

vbinbinyumsft_0-1668500781363.png

Table2:

create with dax formula

Table 2 = {"x","y","z"}

vbinbinyumsft_1-1668500812908.png

2. create a measure with below dax formula

Measure =
VAR _str =
    IF ( ISFILTERED ( 'Table 2'[Value] ), CONCATENATEX ( 'Table 2', [Value] ) )
VAR sum_x =
    SUMX ( ALL ( 'Table' ), [x] )
VAR sum_y =
    SUMX ( ALL ( 'Table' ), [y] )
VAR sum_z =
    SUMX ( ALL ( 'Table' ), [z] )
VAR _a =
    SWITCH (
        SELECTEDVALUE ( 'Table 2'[Value] ),
        "x", sum_x,
        "y", sum_y,
        "z", sum_z
    )
VAR _b =
    SWITCH (
        TRUE (),
        CONTAINSSTRING ( _str, "xy" ), sum_x + sum_y,
        CONTAINSSTRING ( _str, "xz" ), sum_x + sum_z,
        CONTAINSSTRING ( _str, "yz" ), sum_y + sum_z
    )
RETURN
    IF (
        LEN ( _str ) = 3,
        sum_x + sum_y + sum_z,
        SWITCH (
            TRUE (),
            HASONEVALUE ( 'Table 2'[Value] ), _a,
            NOT ( HASONEVALUE ( 'Table 2'[Value] ) ), _b
        )
    )

4. add a slicer with Table2 and card visual with measure

Animation15.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, what if I have not only 3 metrics, but 10? It would require calculating sum for each combination possible... Is there a workaround?

amitchandak
Super User
Super User

@samerhaidar0811 , try a measure like

if ( "x" in values(table[X]) , Sum(Table[X]) , Blank())

+ if ( "y" in values(table[X]) , Sum(Table[y]) , Blank()) 

+ if ( "z" in values(table[X]) , Sum(Table[z]) , Blank()) 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.