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

Lookup Value and return

Hello

 

I need help in creating a measure to valdate/lookup the information on the Invoice level.

 

If all product types in Invoice number is "True" in Exchange then return "1"

AND

If all product types in Invoice number is "False" in Exchange then return "2"

AND

If product types in Invoice number is "True" or "False" in Exchange then return "3"

 

Click here to access the sample report.

 

Thanks

Gaurav

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi @gaurav-narchal  , 

 

Because your file cannot be opened here, so I create a simple example to calculate the Invoice level ; and create a measure as follows:

level =
VAR _count =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Exchange] ),
        ALLEXCEPT ( 'Table', 'Table'[ InvoiceID] )
    )
RETURN
    IF ( _count = 2, 3, IF ( MAX ( [Exchange] ) = "FALSE", 2, 1 ) )

The final output is shown below:

v-yalanwu-msft_0-1621936879214.png

If it still fails to solve your problem, can you re-upload the file?

 

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.  

View solution in original post

5 REPLIES 5
v-yalanwu-msft
Community Support
Community Support

Hi @gaurav-narchal  , 

 

Because your file cannot be opened here, so I create a simple example to calculate the Invoice level ; and create a measure as follows:

level =
VAR _count =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Exchange] ),
        ALLEXCEPT ( 'Table', 'Table'[ InvoiceID] )
    )
RETURN
    IF ( _count = 2, 3, IF ( MAX ( [Exchange] ) = "FALSE", 2, 1 ) )

The final output is shown below:

v-yalanwu-msft_0-1621936879214.png

If it still fails to solve your problem, can you re-upload the file?

 

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.  

Ashish_Mathur
Super User
Super User

Hi,

Do you want the result as a calculated column in your table or as a measure in your visual?


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

@Ashish_Mathur  - I would need this as a measure.

jdbuchanan71
Super User
Super User

We can simplify it a bit more even.

Exchange Check = 
VAR _AllRows = COUNTROWS ( 'Table' )
VAR _TrueRows = CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Exchange] = TRUE )
RETURN 
SWITCH(
    TRUE(),
    _TrueRows = _AllRows, 1,
    _TrueRows = 0, 2,
    3
)
jdbuchanan71
Super User
Super User

@gaurav-narchal 

Try something like this.

Exchange Check = 
VAR _AllRows = COUNTROWS ( 'Table' )
VAR _TrueRows = CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Exchange] = TRUE )
VAR _FalseRows = CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Exchange] = FALSE )
RETURN 
SWITCH(
    TRUE(),
    _TrueRows = _AllRows, 1,
    _FalseRows = _AllRows, 2,
    3
)

jdbuchanan71_0-1621710041661.png

 

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.