Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Date Range Filter

Fact is populated with DateKey and Vendor Key for every submission of data file.   Example:   fctSales   fctsk        DateKey      VendorKey      Measure1   Measure2 1              20010101   ...
  • v-lili6-msft's avatar
    7 years ago

    hi, Anonymous

    After my research, you could try these two way as below:

    1. for Relationship between fact and Vendor exists with direction of 'Both'

    If you filter fctSales table, dimVendor will be filtered too, so you need a new dimVendor table and do not create a relationship with fctSales table.

    Step1:

    Create a new table by this formula

    new dimVendor = dimVendor

    Step2:

    create a measure by this formula

    NOT submitted = var _exsitVendorkey =VALUES(dimVendor[VendorKey]) return
    CALCULATE(MAX('new dimVendor'[VendorName]),FILTER('new dimVendor',NOT( 'new dimVendor'[VendorKey]) IN _exsitVendorkey ))

    Step3:

    Drag VendorKey and VendorName from dimVendor table as Submitted Vendor

    Drag VendorKey and VendorName and measure NOT submitted from new dimVendor table as Not Submitted Vendor

    Result:

    2. If you set Relationship between fact and Vendor exists with direction of 'Single'

    When you filter fctSales table, dimVendor will be not filtered.

    So you could try this way:

    Create two measure

    submitted = var _exsitVendorkey =VALUES(fctSales[VendorKey]) return
    CALCULATE(MAX('dimVendor'[VendorName]),FILTER('dimVendor','dimVendor'[VendorKey] IN _exsitVendorkey ))
    Not submitted = var _exsitVendorkey =VALUES(fctSales[VendorKey]) return
    CALCULATE(MAX('dimVendor'[VendorName]),FILTER('dimVendor',NOT('dimVendor'[VendorKey]) IN _exsitVendorkey ))

    Then Drag VendorKey and VendorName and two measure from dimVendor table

    Result:

     

    here is pbix file that Relationship between fact and Vendor exists with direction of 'Both', please try it.

     

    Best Regards,

    Lin