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

Help on Treat As calculation

Hi All,

 

I am raising this as a new thread my actual problem is solved  which is the below one

 

https://community.powerbi.com/t5/Desktop/Assign-different-value/m-p/2903454#M997567

 

Basically I am trying to show junk values in header apart from selected value in slicer

 

I was suggested to use use below measure

 

Measure = 
SWITCH (
    TRUE (),
    SELECTEDVALUE ( DiscUsers[Type] ) = "U",
        CALCULATE (
            SUM ( 'Table'[Amount] ),
            KEEPFILTERS ( TREATAS ( VALUES ( DiscUsers[User] ), 'Table'[User] ) )
        ),
    SELECTEDVALUE ( DiscUsers[User] ) <> SELECTEDVALUE ( 'Table'[User] ),
        CALCULATE (
            SUM ( 'Table'[Amount] ),
            TREATAS ( VALUES ( DiscUsers[User] ), 'Table'[User] )
        )
)

 

when I am trying to use other slicers like date slicer it is giving wrong results tried using all, all except but still not working.

 

If I use rmovefilters its working fine but user wants to check only specific period data so remove filter wont help

 

first part of calculation is working fine but when I trying to add filter in the second part it is giving wrong results

 

Can someone please suggest.

 

Thanks in advance

 

 

 

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , I have taken a little bit different approch

 

Check the attached file

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

Thank you @amitchandak for your suggestion its working fine. Since I have 30-35 customers I manually created a source file for customer table and used it and its giving me desired O/P one last ask will it be possible to assign 1 and 0 

if selected value then 1 else 0 cause since I have so many customers it is hard to identify the selected name so if we can assign 1 and 0. we can use conditional formating and highlight the selected Customer

Thank you for your help

Hi @Anonymous ,

 

You can modify the return value of the conditional statement of the IF function.

If your problem has been solved, please mark the helpful answer above as a solution and then we are able to close the thread. More people who have the same requirment will find the solution quickly and benefit here, thank you!

 

Best Regards,
Community Support Team _ xiaosun

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @amitchandak ,

 

My data is slighthly different since you are using user1,2... substitute is working fine but my data is as below

praveenpasila_0-1669031978748.png

so I used direct text which is replacing fine

Customer = ADDCOLUMNS(CROSSJOIN(SELECTCOLUMNS( DISTINCT('Table'[Customer]), "User", [Customer] ), DISTINCT('Table'[Customer])), "Disp Customer" , if([Customer] =[User] , [Customer] , "B"))

praveenpasila_1-1669032035907.png

but since everything is assigned with same value which is of no use can we use index or something similar instead of text "B" so we get the desired o/p. please suggest

Thanks in advance

Anonymous
Not applicable

Thank you so much @amitchandak I will try your approach and will let you know how it worked

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors