Forum Discussion
split rows
- Anonymous3 years ago
Hi sa100 ,
Create measures.
Measure = CALCULATE(MAX('Table'[Purchase Cost]),FILTER(ALL('Table'),'Table'[Product]=SELECTEDVALUE('Table (2)'[Product])&&'Table'[Quantity]=SELECTEDVALUE('Table (2)'[Quantity])))Measure 2 = var _1= CALCULATE(SUM('Table'[Purchase Cost]),FILTER(ALL('Table'),'Table'[Product]=SELECTEDVALUE('Table (2)'[Product])&&'Table'[Quantity]<>SELECTEDVALUE('Table (2)'[Quantity]))) var _2=SUMX(FILTER(ALL('Table (2)'),'Table (2)'[Product]=SELECTEDVALUE('Table (2)'[Product])),[Measure]) var _result=_1-_2 var _count=CALCULATE(COUNT('Table (2)'[Product]),FILTER(ALL('Table (2)'),[Measure]=BLANK()&&'Table (2)'[Product]=SELECTEDVALUE('Table (2)'[Product]))) return IF([Measure]<>BLANK(),[Measure],IF(_count=1,_result,MAX('Table (2)'[Quantity])*MAX('Table (2)'[Price per unit])))Best Regards
Community Support Team _ PollyIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi sa100 ,
I have created a simple sample , please refer to my pbix file to see if it helps you.
Create a measure.
Measure =
VAR _1 =
CALCULATE (
MAX ( 'Table'[Purchase Cost] ),
FILTER (
ALL ( 'Table' ),
'Table'[Product] = SELECTEDVALUE ( 'Table (2)'[Product] )
&& 'Table'[Quantity] = SELECTEDVALUE ( 'Table (2)'[Quantity] )
)
)
VAR _2 =
CALCULATE (
MAX ( 'Table'[Unit price] ),
FILTER (
ALL ( 'Table' ),
'Table'[Product] = SELECTEDVALUE ( 'Table (2)'[Product] )
&& 'Table'[Quantity] <> SELECTEDVALUE ( 'Table (2)'[Quantity] )
)
)
VAR _3 =
MAX ( 'Table (2)'[Quantity] ) * _2
RETURN
IF ( _1 = BLANK (), _3, _1 )
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you Anonymous for your reply. This measure is good, but it does not provide all correct answers. For example last row of the ouput
TPM 2175 7833.60 3.60 2001.92
Calculation of 2001.92 total purchase cose in the measure is not correct
Where as in my end result table
TPM 2176 783.36 2176 7833.6
Total purchase cost is 783.36
This purchase cost is calculated from the following rows in table 1
TPM 1000 0.55 550
TPM 1176 0.20 235.2
thank you