Forum Discussion

ammar_cs_2004's avatar
ammar_cs_2004
Frequent Visitor
3 years ago

Determine whether A Date is In-between Two Dates in Power BI

Hi everyone,

I have two tables.The first one is for Asset History The second one is for items Issue for Asset

I want the to do add new column to the second table to bring To Code

 

First Table (Asset Transaction):

Transaction NameAsset CodeStart DateEnd DateTo CodeTo Name
Asset Custodian Opening5930631/12/201718/06/2019S00001EMP 1
Asset Transfer Custodian5930619/06/201924/08/2020S00002EMP 2
Asset Transfer Custodian5930625/08/202011/03/2022S00003EMP 3
Asset Transfer Custodian5930612/03/202203/10/2022S00004EMP 4

 

Second Table (Stock Ledger):

Vr. No.Vr. DateTransaction NameAsset CodeItem CodeItem NameQTYAmountTo Code
10190010521/09/2019Material Issue5930610801010289Printer Ink Cartridge HP # Black 950XL # CN045AN1117 
10190010521/09/2019Material Issue5930610801010292Printer Ink Cartridge HP # 951XL Yellow # CN048AN190 

 

i try this code but not working fine.

 

TO Code =
VAR _occurrenceDate = SELECTEDVALUE('Stock Ledger'[Vr. Date])
VAR _occurrenceCode = SELECTEDVALUE('Stock Ledger'[Asset Code])
RETURN
CALCULATE(
SELECTEDVALUE('Asset Transaction'[To Code]),
FILTER('Asset Transaction',
_occurrenceDate >= 'Asset Transaction'[Start Date] &&
_occurrenceDate <= 'Asset Transaction'[End Date] &&
_occurrenceCode <> BLANK() &&
_occurrenceCode == 'Asset Transaction'[Asset Code]
)
)

 

2 Replies

  • Hello ammar_cs_2004,

     

    Try the below:

     

    To Code =
    VAR _occurrenceDate = 'Stock Ledger'[Vr. Date]
    VAR _occurrenceCode = 'Stock Ledger'[Asset Code]
    RETURN

    CALCULATE(
        FIRSTNONBLANK('Asset Transaction'[To Code], 1)

        , _occurrenceCode == 'Asset Transaction'[Asset Code]

        , _occurrenceCode <> BLANK()

        , _occurrenceDate >= 'Asset Transaction'[Start Date]

        && _occurrenceDate <= 'Asset Transaction'[End Date]

    )

    • ammar_cs_2004's avatar
      ammar_cs_2004
      Frequent Visitor

      thanks for reply but it is not working have error 

      (The True/False expression does not specify a column. Each True/False expressions used as a table filter expression must refer to exactly one column.)