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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to filter data based on two columns

Hi,

 

I am new to power bi platform, can someone help me.

 

I want to filter my table/data in my visuals based two columns. 

TableTable

for example i have a table with columns as transaction, period, code , Employee, amount, quantity, nature. 

And now in my table visual i want see results based on period and Nature column,

Data should filter if corresponding values for P1 has both 'A' and 'B' then it should return values else nothing. it shuould not pick other periods data. 

I expect to see only P1 results. P2 should not seen in any visuals because it does not have 'A' value it just had 'B'. 

ResultResult

Result of visual table as below

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Anonymous 

here is a workaround.

Column = IF(CALCULATE(DISTINCTCOUNT('Table (2)'[NATURE]),ALLEXCEPT('Table (2)','Table (2)'[period]))=1,"no","Yes")

then add a filter and select Yes





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

6 REPLIES 6
ryan_mayu
Super User
Super User

@Anonymous 

here is a workaround.

Column = IF(CALCULATE(DISTINCTCOUNT('Table (2)'[NATURE]),ALLEXCEPT('Table (2)','Table (2)'[period]))=1,"no","Yes")

then add a filter and select Yes





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Hey @ryan_mayu , it worked, Thank you so much 😊. Do you mind explaining the formula, i am not understanding how to start read, is it from inner to outer or outer to inner function?

@Anonymous 

it's counting the nature values for each period. If only one value, return no, otherwise retun yes.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous , Try this type of measure for all measures like quantity, amount etc

 


new Quantity =
var _1 = calculate(sum(Table[Quantity], filter(allselected(Table), Table[code] = max(Table[code]) && Table[period] = max(Table[period]) && Table[Nature] = "A"))
var _2 = calculate(sum(Table[Quantity], filter(allselected(Table), Table[code] = max(Table[code]) && Table[period] = max(Table[period]) && Table[Nature] = "B"))
return
calculate(sum(Table[Quantity]), filter(Table, not(isblank(_1)) && not(isblank(_2))))

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
Anonymous
Not applicable

Hey @amitchandak , Thanks for replying, i didn't understood why code column was selected, i need only period and nature to be used.

 

Can you please explain 

 

Thanks,

Shravz

ChaitanyaTagare
Microsoft Employee
Microsoft Employee

You can create two slicers on top of the table.

1.Drag slicers controll from visualization section.

2. Slicer1- Period  (drag period field into this slicer)

3. Slicer2- Nature (drag Nature field into this slicer)

When you select P1 period from slicer1 it will show nature A and B

and for P2 it should show values for nature B only.

 

With slicer2 you will able to select Nature A or B and corrosponding period.

Let me know if this helps.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors