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
Helpful_Fun4848
Helper III
Helper III

Showing latest date value with multiple conditions

Hi all,

I have the following set of data:

 

CompanyPO DateItem#Unit PriceIsNETSupplier
0011/6/20211101.23TRUEABC
0023/4/20211111.45FALSEBCD
0035/8/20211121.56TRUECBE
0018/8/20211111.3FALSEDEF
0039/6/20211121.89FALSECBE

 

I need to create a matrix or table showing the Unit Price (which divided into CPG and NET) for the latest PO date in the following format:

 

Item#Supplier
 CPG PriceNET Price
   

 

CPG Price condition: IsNET = FALSE + Company <> 0001

 

NET Price condition: (IsNET = TRUE + Company <> 0001) + Company = 0001

 

Much appreciated for any help!!

 

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

Hi @Helpful_Fun4848 ,

 

CPG = 
var _latest = CALCULATE(MAX('Table'[PO Date]),FILTER('Table','Table'[IsNET]="FALSE"&&'Table'[Company]<>"0001"))
return
CALCULATE(SUM('Table'[Unit Price]),FILTER('Table','Table'[PO Date]=_latest))
NET = 
var _latest = CALCULATE(MAX('Table'[PO Date]),FILTER('Table',('Table'[IsNET]="TRUE"&&'Table'[Company]<>"0001")||'Table'[Company]="0001"))
return
CALCULATE(SUM('Table'[Unit Price]),FILTER('Table','Table'[PO Date]=_latest))

Capture.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

7 REPLIES 7
v-jayw-msft
Community Support
Community Support

Hi @Helpful_Fun4848 ,

 

CPG = 
var _latest = CALCULATE(MAX('Table'[PO Date]),FILTER('Table','Table'[IsNET]="FALSE"&&'Table'[Company]<>"0001"))
return
CALCULATE(SUM('Table'[Unit Price]),FILTER('Table','Table'[PO Date]=_latest))
NET = 
var _latest = CALCULATE(MAX('Table'[PO Date]),FILTER('Table',('Table'[IsNET]="TRUE"&&'Table'[Company]<>"0001")||'Table'[Company]="0001"))
return
CALCULATE(SUM('Table'[Unit Price]),FILTER('Table','Table'[PO Date]=_latest))

Capture.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
lbendlin
Super User
Super User

"NET Price condition: (IsNET = TRUE + Company <> 0001) + Company = 0001"

 

This will always evaluate to false.  Please check the definition.

@lbendlin 

 

The statement on my OP may not be correct. The 2 conditions for NET Price:

1. IsNET = TRUE 

2. Everything from Company 0001 including if IsNET = FALSE

 

CPG = 'Table'[IsNET]=FALSE() && 'Table'[Company]<>"001"
NET = 'Table'[IsNET]=TRUE() || 'Table'[Company] = "001"

 

 

These are calculated columns - no need for measures. Note that they are complementary, so you could also say

 

NET = NOT CPG

@lbendlin 

 

I need to grab the value of the Unit Price for the latest PO Date only. I don't think the calculated column on your post above did just that, right?

 

Much appreciated for trying to help!!

Based on your sample data, what would be the expected outcome?  I'm still not clear on your process logic.

@lbendlin 

 

So, this is my data:

 

CompanyPO DateItem#Unit PriceIsNETSupplier
00011/6/2021110$1.23TRUEABC
00023/4/2021111$1.45FALSEBCD
00035/8/2021112$1.56TRUECBE
00018/8/2021111$1.30FALSEDEF
00039/6/2021112$1.89FALSECBE
000310/1/2021110$1.30TRUEABC

 

And this is the outcome:

Supplier NameCBEABC
Item#CPGNETCPGNET
112$1.89$1.56  
110   $1.30

 

Price on the outcome table is Unit Price from the latest PO Date for the respective supplier.

 

If I can summarize all the conditions:

1. Both CPG and NET =  Unit Price from the latest PO Date

2. CPG: IsNET = FALSE

3. NET: IsNET = TRUE

4. Company 0001 = NET (even if IsNET = FALSE)

 

The table outcome is not correct after I pasting it here. 

It should be:

     CBE            ABC

CPG NET    CPG NET

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.