Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Need to Compare Requirement vs Availability

Hello Dax Experts,

 

I have 3 tables -

 

Table 1 : MachineDetails (Machine , Serial No, Mandatory Repair, Mandatory Repair Hours Type, Location). This Table gives details of machine. Serial No of machine will be unique. Mandatory Repair gives information that mandatory repair is required or not. Mandatory Repair Hours type give information that it is 500 Hours Repair or 1000 Hours Repair and Location is location of that machine.

 

Machine Serial NoMandatory RepairMandatory Repair Hours TypeLocation
A100Y500 HoursX
A101N X
A102N X
A103Y1000 HoursX
B501Y500 HoursZ
B502Y500 HoursZ
B503N Z
B504N Z

 

Table 2:  PartsRequired (Machine, Mandatory Repair Hours Type, Part No, Qty). This table gives information about the parts required to do Mandatory Repair machine wise. For each machine quantity of parts for 500/1000 hours repair can be obtained from here.

 

MachineMandatory Repair Hours TypePart NoQty
A500 HoursABC1231
A500 HoursABC3451
A500 HoursABC6781
A500 HoursABC910111
A500 HoursABC8871
A1000 HoursABC1231
A1000 HoursABC3451
A1000 HoursABC7651
A1000 HoursABC4451
A1000 HoursABC3401
B500 HoursABC1231
B500 HoursPQR7891
B1000 HoursABC1231
B1000 HoursPQR9901

 

 

Table 3: DealerStock ( Dealer, Location, Part No, Stock). This table gives infromation about dealer's stock of parts. At one location only one dealer will be there.

 

DealerLocationPart NoStock
A1XABC1232
A1XABC3452
A1XABC6780
A1XABC910111
A1XABC8871
A1XABC7651
A1XABC44520
A1XABC34014
A1XPQR7894
A1XPQR99067
A2YABC1233
A2YABC3457
A2YABC6782
A2YABC910117
A2YABC8875
A2YABC7657
A2YABC4459
A2YABC3404
A2YPQR7892
A2YPQR9908

 

Slicers on reports will be Machine and location.

 

I want to Compare Requirement of Service vs Availability against Mandatory Service Hour Type(from table 1)

 

If a user selects location X in the report the requirement will be 2 (one for 500 Hours and one for 1000 Hours). But availaibilty will be 1 as Part - ABC678 is out of stock for location X.

 

Expected output for Location X and Machine A will be something like-

Developer_2202_0-1634883480870.png

 

Request you to please help here.

@Greg_Deckler @parry2k @PaulDBrown @AllisonKennedy @amitchandak @AlexisOlson 

 

Thanks in Advance!

 

 

3 REPLIES 3
Anonymous
Not applicable

Hello @Greg_Deckler ,

 

Thank you very much for inputs but it is not giving result as expected.

I need to take the count of machines serial number when Service is possible but measure is returning 1 for 500 Hours when Machine A is selected.

 

For machine A type, two services are required (For serial no 100 and 103).

But for serial no 100 service is not possible as one of the part required(ABC678) is out of stock.


So when user selects Machine A. 1 count should come as availability against 1000 hours.

 

Measure output is showing 1 against 500 Hours.

 

Developer_2202_0-1635145283755.png

 

If possible can I please have PBIX also in which you have solved it? It will be great help and I will make sure that I am not doing anything worng.

Thank you very much in Advance!

Kind Regards.

@Anonymous The measure I created was for the "Available" cell in your image. I didn't actually test it in a PBIX file so the fact that it didn't have any syntax errors is a miracle.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

@Anonymous OK, so a little hard to put the puzzle pieces together on this and I assume you meant ABC678 is out of stock since that is 0. I'm thinking someting along the lines of:

Available Measure =
  VAR __Machine = MAX('Table1'[Machine])
  VAR __LocationType = MAX('Table1'[TypeLocation])
  VAR __MandatoryRepairHours = MAX('Table1'[Mandatory Repair Hours])
  VAR __Table = 
    ADDCOLUMNS(
      ADDCOLUMNS(
        ADDCOLUMNS(
          FILTER(ALL('Table2'),[Machine]=__Machine && [MandatoryRepairHours]=__MandatoryRepairHours),
          "__LocationType",__LocationType
        ),
        "__Stock",
          VAR __PartNo = [Part No]
        RETURN
          MAXX(FILTER('Table3',[Part No]=__PartNo && [Location]=__LocationType),[Stock])
      ),
      "__Diff" = IF([Qty] <= [__Stock],1,0)
    )
  VAR __Count = COUNTROWS(FILTER(__Table, [__Diff] = 0))
RETURN
  IF(ISBLANK(__Count) || [__Count] = 0,0,1)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.