Calculate Lines with same condition

srehman

Board Regular
Joined
Jan 4, 2020
Messages
210
Office Version
  1. 2016
Platform
  1. Windows
Hi Team,
Need your thoughts i am doing some mistake not achieving desired results by using DAX.
please provide your advice.

I have total 10841 Lines or rows which is combination of following condition.

I am using Power Pivot DAX to calculate those Lines in which SKU has blank() and DIS both condition on same location.

I have written some dax.

CountALLLines:=COUNTROWS(SOHP) -->working correct total lines 10841

location check DIS:=CALCULATE([countline],SOHP[Condition Code]="DIS") -->
working correct total lines 51

location check Good:=CALCULATE([countline],FILTER(SOHP,SOHP[Condition Code]=BLANK())) -->working correct total lines 10634
Now i want to check

i want to check (SKU has blank() and DIS both condition on same location.

But following formula not calculating correct

===============================================================================================
following both formula not working
===========================================================================================
location check Good&DIS:=CALCULATE([countline],FILTER(SOHP,SOHP[Condition Code]="DIS" && SOHP[Condition Code]=BLANK()))
or
location check Good&DIS(try2):=CALCULATE([countline],SOHP[Condition Code]="DIS" ,SOHP[Condition Code]=BLANK())

================================================================================================


SOH Condition check.xlsx
PQ
3Condition CodeCount of SKU
4(blank)10634
5DAM2
6DIS51
7INS48
8NCD94
9QAH10
10RET2
Sheet2


Expected Result
SOH Condition check.xlsx
PQRS
14SKULocation(blank)DIS
1513481550KAR08511
1616026620KAR19011
1747774130EO03210C31
Sheet2
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi,

Not an easy answer with the information provided.
Working from the assumption:
  1. your data file holds 10841 lines; and
  2. the condition column is a column which holds 1 condition per line; and
  3. you don't show what the fieldname [countline] is; and
  4. [countline] does actually count the lines; and
  5. you want to count the line where the condition meets 1 of the criteria requested.
assuming: you're looking for an "OR" function.

So if above is correct, try this:
location check Good&DIS(try2):=CALCULATE([countline],OR(SOHP[Condition Code]="DIS" ,SOHP[Condition Code]=BLANK()))

which should come up with 10685 lines (10634 from blanks and 51 from DIS)

Hope this helps
 
Upvote 0
Hi,
Thanks for your time & effort really appreciate it.

Apologies for less info.

Please review now

Not an easy answer with the information provided.
Working from the assumption:
  1. your data file holds 10841 lines; and ---> Yes
  2. the condition column is a column which holds 1 condition per line; and---> Yes (Blank) means good condition
  3. you don't show what the fieldname [countline] is; and-----> here i have counted all rows
  4. [countline] does actually count the lines; and------> Yes
  5. you want to count the line where the condition meets 1 of the criteria requested. ---> I want to check those SKU lines or rows which must have condition of Blank() and DIS ( Which is i derived from power query 51 lines of Blank() & 50 Lines of DIS.
  6. How can i check unique SKU falls in both condition & total number of lines.
Example data

2 lines of Good stock and 1 DIS we need to count , total 3 lines of 1 SKU
SOH Condition check.xlsx
ABCDEFGHIJ
3SKUSKU DescriptionObsolete?LocationLocation ZoneSub ZoneQty On HandPallet TypeMove DateCondition Code
411073160G 2800 AUSNKAR00240BLK01BULK180PLT43815
511073160G 2800 AUSNKAR02040BLK01BULK96PLT43811DIS
611073160G 2800 AUSNKAR04640BLK01BULK216PLT43815
711073160G 2800 AUSNKAR08040BLK01BULK143PLT43808INS
Sheet6

assuming: you're looking for an "OR" function.

So if above is correct, try this:
location check Good&DIS(try2):=CALCULATE([countline],OR(SOHP[Condition Code]="DIS" ,SOHP[Condition Code]=BLANK()))

which should come up with 10685 lines (10634 from blanks and 51 from DIS)

Hope this helps
 
Upvote 0
Hi I have done some calculation now , but i cannot view in pivot table value field
 

Attachments

  • Correctly calculated but cant view in value filed of pivot table.PNG
    Correctly calculated but cant view in value filed of pivot table.PNG
    73.1 KB · Views: 12
  • Calculated in Measure Grid but cannot view in Pivot Table.PNG
    Calculated in Measure Grid but cannot view in Pivot Table.PNG
    62.8 KB · Views: 11
Upvote 0
Hi,

Not sure what you aiming for because you've changed from number of Records to Unique SKU but

to get the result on:
  1. all lines: location check Good&DIS(try2):=CALCULATE( COUNTROWS(SOHP) ,OR(SOHP[Condition Code]="DIS" ,SOHP[Condition Code]=BLANK()))
  2. Unique SKU: location check Good&DIS(try2):=CALCULATE( DISTINCTCOUNT(SOHP[SKU]) ,OR(SOHP[Condition Code]="DIS" ,SOHP[Condition Code]=BLANK()))
 
Upvote 0
Hi,

Not sure what you aiming for because you've changed from number of Records to Unique SKU but

to get the result on:
  1. all lines: location check Good&DIS(try2):=CALCULATE( COUNTROWS(SOHP) ,OR(SOHP[Condition Code]="DIS" ,SOHP[Condition Code]=BLANK()))
  2. Unique SKU: location check Good&DIS(try2):=CALCULATE( DISTINCTCOUNT(SOHP[SKU]) ,OR(SOHP[Condition Code]="DIS" ,SOHP[Condition Code]=BLANK()))
Yes its working could you assist when i dropping this measures in pivot table value header can't view any numbers. While all DAX calculations are correct.
 
Upvote 0
Hi,

Don't know how because i've tested it on my end and everything works like it should.
 
Upvote 0

Forum statistics

Threads
1,223,775
Messages
6,174,458
Members
452,566
Latest member
Bonnie_bb

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top