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
LeandroCorrea
Frequent Visitor

problem with multiple selection in sumx

I need a file where the selected data appears normally and other products appear grouped (classified as others). When the selection is unique, it works perfectly, but when the selection is multiple it does not work

 

To function it organizes a structure with 3 tables.
Base = Database
Auxiliar2 = GROUPBY (Base; Base [Cliente])
table2= UNION (GROUPBY (SELECTCOLUMNS (Base; "Cliente"; Base [Cliente]); Cliente]; GROUPBY (SELECTCOLUMNS (Base; "Cliente"; " Outros "); [Cliente]))

 

Auxiliar2 = Used for filter
table2 = used as the graph axis

 

 

mensure 2 =
IF (FILTROS (Tabela 2 [Cliente]) = FILTROS (Auxiliar2 [Cliente]);
SUMX (FILTER (Base; Base [Cliente] = FILTROS (Auxiliar2 [Cliente]); Base [Valor]);
IF (FILTROS (Table2 [Cliente]) = "Outros";
SUMX (FILTER (Base; Base [Cliente] <> FILTROS (Auxiliar2 [Cliente]); Base [Valor])))

 

Print 1 table.pngPrint 2 - filter.png

 

1 ACCEPTED SOLUTION

Hi @LeandroCorrea

 

Please follow the link. It has the exact solution for you. I tried it on the pbix file you uploaded. It worked perfectly.

http://sqljason.com/2017/03/dynamic-grouping-in-power-bi-using-dax.html

 If it works for you pleasse accept this as solution and also give KUDOS.

Cheers

CheenuSing

 

 

 

 

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

View solution in original post

9 REPLIES 9
v-huizhn-msft
Employee
Employee

Hi @LeandroCorrea,

I create sample table and try to reproduce your scenario. When the selection is unique, it still doesn't work. It only shows the selection value, the "Outros" is not shown as follows. If the slicer filter the x-axis, how to display "Outros"? There is related value in slicer. So please share your .pbix file for further analysis. 

1.PNG

My measure is shown below.

mensure 2 = 
IF (FILTERS( table2[Cliente]) = FILTERS(Auxiliar2[Cliente]),
SUMX (FILTER (Base, Base [Cliente] = FILTERS( Auxiliar2[Cliente])),Base[Valor]), 
IF (FILTERS( table2[Cliente]) = "Outros", 
SUMX (FILTER (Base, Base [Cliente] <> FILTERS(Auxiliar2[Cliente])), Base[Valor])))


And when the selection is multiple, there will be some values compared to some values in this part: FILTERS( table2[Cliente]) = FILTERS(Auxiliar2[Cliente]), the logic is wrong. So it didn't work correctly.

In addition, please use the following formula and check if it works fine.

Measure =
IF (
    SELECTEDVALUE ( Auxiliar2[Cliente] ) <> "Outros",
    SUMX (
        FILTER ( Base, Base[Cliente] = FILTERS ( Auxiliar2[Cliente] ) ),
        Base[Valor]
    ),
    SUMX (
        FILTER ( Base, Base[Cliente] <> FILTERS ( Auxiliar2[Cliente] ) ),
        Base[Valor]
    )
)


Best Regards,
Angelia

how do I share the pbix file here?
Is there somewhere here on the page to attach or only by external link?

Hi @LeandroCorrea,

You can upload the .pbix file as attachments as follows.

1.PNG

Or you can store your .pbix file in onedrive, and post the share link.

2.PNG

Best Regards,
Angelia

follows the file, as I had said, with simple selection works perfectly. It brings the selected customer into one column and groups the other clients into the "other" column of the chart. I need to select two clients, example (D and C) and the graph presents these three columns (D, C and one of Others)

 

Link: https://1drv.ms/u/s!AjuJi3nCDZmbhSpMIJVpuZPHR4eG

Hi @LeandroCorrea

 

Please follow the link. It has the exact solution for you. I tried it on the pbix file you uploaded. It worked perfectly.

http://sqljason.com/2017/03/dynamic-grouping-in-power-bi-using-dax.html

 If it works for you pleasse accept this as solution and also give KUDOS.

Cheers

CheenuSing

 

 

 

 

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

Thank you my friend! excellent solution worked perfectly for what I needed.

I'm still newbie, but this type of measure is considered at what level?
intermediary or basic?

Hi @LeandroCorrea

 

I would say intermediary.

 

Good to hear your problem was solved.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

@v-huizhn-msft and @CheenuSing, thanks for the help! Have a great weekend

Sorry, I do not speak English very well.

Hi @LeandroCorrea,

The difficult is how to change the part where the selection is multiple, there will be some values compared to some values in this part: FILTERS( table2[Cliente]) = FILTERS(Auxiliar2[Cliente])

Usually we use slicer to affect the chart directly. It affects measure in your chart. While use the slicer filter the x-axis directly, the Outros is not including in slicer, so it's hard to find a workaround. I will post the update if I find solution. 

Best Regards,
Angelia

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.

Top Solution Authors