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

Tricky Switch or If Formula

Hi Experts

 

See attached sample PBIX file i am trying to Produce a  P&L Statement and i Cannot transpose the data as my final table has 150 columns in it. 

 

What i am trying to Produce is the folllowing table in Power BI - which is the sate of my P&L...

  USD 
 Gross Sales    25,155.00
 Rebate          640.00
 Net Sale    24,515.00

 

Sample File

https://www.dropbox.com/s/8b6zd95vxn7mmr9/Net%20Sales.pbix?dl=0 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please correct me if I wrongly understood your question.

I am not sure why the two tables are connected, but I did not change any relationship, and I just left it as it is.

Please check the below picture and the measure, whether it is what you are looking for.

 

Picture1.png

 

USD =
SWITCH (
SELECTEDVALUE ( DimHierarchy[Index] ),
1, SUM ( FACTSales[Gross Sales (USD)] ),
2, CALCULATE ( SUM ( FACTSales[Rebate (USD)] ), REMOVEFILTERS ( DimHierarchy ) ),
3, CALCULATE ( SUM ( FACTSales[Net Sales (USD)] ), REMOVEFILTERS ( DimHierarchy ) )
)

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

6 REPLIES 6
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please correct me if I wrongly understood your question.

I am not sure why the two tables are connected, but I did not change any relationship, and I just left it as it is.

Please check the below picture and the measure, whether it is what you are looking for.

 

Picture1.png

 

USD =
SWITCH (
SELECTEDVALUE ( DimHierarchy[Index] ),
1, SUM ( FACTSales[Gross Sales (USD)] ),
2, CALCULATE ( SUM ( FACTSales[Rebate (USD)] ), REMOVEFILTERS ( DimHierarchy ) ),
3, CALCULATE ( SUM ( FACTSales[Net Sales (USD)] ), REMOVEFILTERS ( DimHierarchy ) )
)

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Fowmy
Super User
Super User

@Anonymous 

Follow steps in the attachement.

Fowmy_0-1619458167599.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Excellent idea but i need to keep region channel and year and month columns,....

@Anonymous 

I included the other fields as well, please check the attachemnt.

Fowmy_0-1619463389198.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

amitchandak
Super User
Super User

@Anonymous , to me this seems like a measure in a row using " Show on row"

 

https://www.burningsuit.co.uk/blog/2019/04/7-secrets-of-the-matrix-visual/

Anonymous
Not applicable

Hi Amit - that is not going to work in the long run when doing income statements...

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.