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
Paulyeo11
Impactful Individual
Impactful Individual

Why my expression not return NET_PROFIT ?

Hi All

 

My expression below working fine no error :-

 
PNL =
SWITCH(TRUE(),
'Table'[GL CODE]>=20000 &&'Table'[GL CODE]<30000,"COGS",
'Table'[GL CODE]>=40000 &&'Table'[GL CODE]<50000,"REV",
'Table'[GL CODE]>=80000 && 'Table'[GL CODE]<100000,"EXP",
'Table'[GL CODE]>=10000 && 'Table'[GL CODE]<100000,"NET_PROFIT",

BLANK())
The issue is it does not display NET_PROFIT .
Hope some one can advise me why ?
Paul
1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @Paulyeo11 ,

Because all these conditions: [20000,30000), [40000,50000), [80000,100000)  are in the range of [10000,100000).

The picture below may help you understand.

10.21.1.1.PNG

If the condition"NET_PROFIT"  is written in the first, the following conditions will "cover" it.

And If it  is written in the last, we could use IF( ) statement to understand:  [10000,100000) is not the negative condition of the above condition, so the last logical sentence could not run. 

Column =
IF (
    'Table'[GL CODE] >= 20000
        && 'Table'[GL CODE] < 30000,
    "COGS",
    IF (
        'Table'[GL CODE] >= 40000
            && 'Table'[GL CODE] < 50000,
        "REV",
        IF (
            'Table'[GL CODE] >= 80000
                && 'Table'[GL CODE] < 100000,
            "EXP",
            IF (
                'Table'[GL CODE] >= 10000
                    && 'Table'[GL CODE] < 100000,
                "NET_PROFIT",
                BLANK ()
            )
        )
    )
)

Maybe you could create one more column for "NET_PROFIT" or apply conditional formatting for the PNL column.

Measure =
IF (
    MAX ( 'Table'[GL CODE] ) >= 10000
        && MAX ( 'Table'[GL CODE] ) < 100000,
    "Yellow"
)

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

 

Best Regards,
Eyelyn Qin

View solution in original post

8 REPLIES 8
v-eqin-msft
Community Support
Community Support

Hi @Paulyeo11 ,

Because all these conditions: [20000,30000), [40000,50000), [80000,100000)  are in the range of [10000,100000).

The picture below may help you understand.

10.21.1.1.PNG

If the condition"NET_PROFIT"  is written in the first, the following conditions will "cover" it.

And If it  is written in the last, we could use IF( ) statement to understand:  [10000,100000) is not the negative condition of the above condition, so the last logical sentence could not run. 

Column =
IF (
    'Table'[GL CODE] >= 20000
        && 'Table'[GL CODE] < 30000,
    "COGS",
    IF (
        'Table'[GL CODE] >= 40000
            && 'Table'[GL CODE] < 50000,
        "REV",
        IF (
            'Table'[GL CODE] >= 80000
                && 'Table'[GL CODE] < 100000,
            "EXP",
            IF (
                'Table'[GL CODE] >= 10000
                    && 'Table'[GL CODE] < 100000,
                "NET_PROFIT",
                BLANK ()
            )
        )
    )
)

Maybe you could create one more column for "NET_PROFIT" or apply conditional formatting for the PNL column.

Measure =
IF (
    MAX ( 'Table'[GL CODE] ) >= 10000
        && MAX ( 'Table'[GL CODE] ) < 100000,
    "Yellow"
)

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

 

Best Regards,
Eyelyn Qin

Hi Eyelyn

Thank you for sharing and provide me detail explianation . 

i try both of the expression is share. 

I still cannot figure how how to compute the net profit amount . 

it is possible you share the PBI file with me ?

Paul Yeo

@Paulyeo11 ,

if you see the table NET PROFIT is covering all other 3 metric values where your GL CODE is between 20000 and 89999, and you are trying to didvide the values between as below which is your DAX and also for net profit again you are referring the GL CODE from 10000 to 100000 whcih is already covered on the other Metrics. 

Because of whcih either you can get Net Profit as th total column or the other 3 defined values. 

Table'[GL CODE]>=80000 && 'Table'[GL CODE]<100000,"EXP",
'Table'[GL CODE]>=40000 &&'Table'[GL CODE]<50000,"REV",
'Table'[GL CODE]>=20000 &&'Table'[GL CODE]<30000,"COGS",

manikumar34_0-1603267937007.png

 

 

Regards, 

Manikumar





If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




Hi Sir

I think my raw data example is not correct.

I should create a correct raw data , so that i can develop a P&L statement.

As it have been confirm by so many expert here.

Paul Yeo

@Paulyeo11 , 

 

According your claculation Net Pfofit is on the highest level and calculating on all the values of the column. So your Net Profit will  become entire column vlaue else you can have other values apart from Net Profit.

 

In this case have two calculated columsn one with Net Profit and the other calculated column with other metrics. 

 

Regards, 

Manikumar





If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




manikumar34
Solution Sage
Solution Sage

@Paulyeo11 

I see you have already passed those values which are between 10000 to 100000 and again you are trying to pass the same on Net Profit. This makes the Value Contradiction. Because of which if you take Net Profi first you can see all the columns with Net Profit and if you takle at last you don'y see net profit. 

 




If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




amitchandak
Super User
Super User

@Paulyeo11 , if it 10000 then it should be at last if 100,000 then it should be first

 

PNL =
SWITCH(TRUE(),
'Table'[GL CODE]>=100000 && 'Table'[GL CODE]<100000,"NET_PROFIT",
'Table'[GL CODE]>=80000 && 'Table'[GL CODE]<100000,"EXP",
'Table'[GL CODE]>=40000 &&'Table'[GL CODE]<50000,"REV",
'Table'[GL CODE]>=20000 &&'Table'[GL CODE]<30000,"COGS",

 


BLANK())

or


PNL =
SWITCH(TRUE(),

'Table'[GL CODE]>=80000 && 'Table'[GL CODE]<100000,"EXP",
'Table'[GL CODE]>=40000 &&'Table'[GL CODE]<50000,"REV",
'Table'[GL CODE]>=20000 &&'Table'[GL CODE]<30000,"COGS",
'Table'[GL CODE]>=10000 && 'Table'[GL CODE]<100000,"NET_PROFIT",

 

BLANK())

Hi Amit

https://www.dropbox.com/s/udjf31pw0zsjegd/C0021%20GL_%20TDS%20v0003.pbix?dl=0

I have try both your expression , NET PROFIT never appear

Paul

 

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.