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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Use slicer to filter values in at least 1 of 2 fields

Firstly, thank you for wanting to help!

 

I currently have data that looks something like this:

 

First Side Code

Second Site Code

Audio

Video

Audio Poor

Video Poor

ABC

DEF

1

0

1

0

DEF

XYZ

2

2

1

1

XYZ

FGH

1

1

0

0

 

I would like to get the data to something like this:

 

Site Code

Audio

Video

Audio Poor

Video Poor

ABC

1

0

1

0

DEF

3

2

2

1

XYZ

3

3

1

1

FGH

1

1

0

0

 

This would ultimately allow me to create a slicer returning all of the data for my chosen site regardless of whether it was the first site, second site or both (if both data should only be counted once).

I am pretty new to Power BI so detailed answers would be appreciated. Thanks!

1 ACCEPTED SOLUTION

Hi @Anonymous

 

I just needed to use a different summarisation function.  Please try this calculated table instead

 

 

New Table = 
VAR T1 =  UNION
        (
        SELECTCOLUMNS('Table1',"Site Code",[First Side Code],"A",[Audio] , "V",[Video] , "A Poor",[Audio Poor] , "V Poor",[Video Poor]),
        SELECTCOLUMNS('Table1',"Site Code",[Second Site Code],"A",[Audio] , "V",[Video] , "A Poor",[Audio Poor] , "V Poor",[Video Poor])
        )
RETURN
   GROUPBY(
       T1,
       [Site Code],
       "Audio",SUMX(CURRENTGROUP(),[A]),
       "Video",SUMX(CURRENTGROUP(),[V]),
       "Audio Poor",SUMX(CURRENTGROUP(),[A Poor]),
       "Video Poor",SUMX(CURRENTGROUP(),[V Poor])
       )

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

10 REPLIES 10
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @Anonymous

 

This calculated table gets close, but seems to be overcounting.  Do you have a special rule to be applied when the item is a secondary code?  I have attached a PBIX file.

 

Table = 
SUMMARIZE(
    UNION
        (
        SELECTCOLUMNS('Table1',"Site Code",[First Side Code],"Audio",[Audio] , "Video",[Video] , "Audio Poor",[Audio Poor] , "Video Poor",[Video Poor]),
        SELECTCOLUMNS('Table1',"Site Code",[Second Site Code],"Audio",[Audio] , "Video",[Video] , "Audio Poor",[Audio Poor] , "Video Poor",[Video Poor])
        ),
        [Site Code],
        "Audio" , SUM(Table1[Audio]),
        "Video" , SUM('Table1'[Video]) ,
        "Audio Poor" , SUM('Table1'[Audio Poor]) ,
        "Video Poor" , SUM('Table1'[Video Poor])
        
        
        )

image.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

Thanks @Phil_Seamark for giving it a go!

 

To answer your question - it's simply no.

 

Does looking at it as 2 tables help at all?

 

First Side Code

Audio

Video

Audio Poor

Video Poor

ABC

1

0

1

0

DEF

2

2

1

1

XYZ

1

1

0

0

 

 

Second Site Code

Audio

Video

Audio Poor

Video Poor

DEF

1

0

1

0

XYZ

2

2

1

1

FGH

1

1

0

0

Hi,

 

If data is in two Tables, then they can simply be appended.  The appended Table can then be grouped on the first column.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Anonymous

 

I just needed to use a different summarisation function.  Please try this calculated table instead

 

 

New Table = 
VAR T1 =  UNION
        (
        SELECTCOLUMNS('Table1',"Site Code",[First Side Code],"A",[Audio] , "V",[Video] , "A Poor",[Audio Poor] , "V Poor",[Video Poor]),
        SELECTCOLUMNS('Table1',"Site Code",[Second Site Code],"A",[Audio] , "V",[Video] , "A Poor",[Audio Poor] , "V Poor",[Video Poor])
        )
RETURN
   GROUPBY(
       T1,
       [Site Code],
       "Audio",SUMX(CURRENTGROUP(),[A]),
       "Video",SUMX(CURRENTGROUP(),[V]),
       "Audio Poor",SUMX(CURRENTGROUP(),[A Poor]),
       "Video Poor",SUMX(CURRENTGROUP(),[V Poor])
       )

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

@Phil_Seamark- can you send me the update Power BI file?

Sure,

 

Sorry, I should have added that to my earlier reply.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

Great - thank you very much @Phil_Seamark!

 

If you don't mind, I have one more question - I actually have a lot of additional columns and measures in my original table is there a quicker way for me to pull them through?

You can try the same approach in the Power Query Editor.  

 

Basically, make two copies of your source table.  Remove the [First Site Code] column from one and then the [Second Site Code] column from the other.  Once you have done that you can append the two queries on top of each other.  This won't aggregate the rows that appear in both - so you will still need to write some "grouping" code in PQ or DAX, whichever you prefer.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

I think the grouping is causing rows that have the same site for first and second, to be counted twice. In the original question, I did mention that I was only looking for these to be counted once.

 

Try adding another line of data to the table and you will see:

data original.pngdouble counting.png

 

HI @Anonymous

 

I think we just need to add a FILTER to the second table in the UNION function as follows

 

Table = 
VAR T1 =  UNION
        (
        SELECTCOLUMNS('Table1',"Site Code",[First Side Code],"A",[Audio] , "V",[Video] , "A Poor",[Audio Poor] , "V Poor",[Video Poor]),
        SELECTCOLUMNS(FILTER('Table1','Table1'[First Side Code]<>'Table1'[Second Site Code]),"Site Code",[Second Site Code],"A",[Audio] , "V",[Video] , "A Poor",[Audio Poor] , "V Poor",[Video Poor])
        )
RETURN
   GROUPBY(
       T1,
       [Site Code],
       "Audio",SUMX(CURRENTGROUP(),[A]),
       "Video",SUMX(CURRENTGROUP(),[V]),
       "Audio Poor",SUMX(CURRENTGROUP(),[A Poor]),
       "Video Poor",SUMX(CURRENTGROUP(),[V Poor])
       )


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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.