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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
adeelnazir
Helper I
Helper I

How to deal 2 periods (4 dates) with two date tables in Power BI

Hi

 

I need to show the current period (start and end date) vs the previous period (start and end date) difference in a single visual.

I've created two date dimensions d1 and d2. 

Created proper relationship 1-many with d1, but d2 is un-link(in-active relationship).

 

I've two slicers like in the below image. 1st slicer is from active date table d1 and 2nd slicer is from in-active data table d2.

Respective min-max dates are shown below image.

 

adeelnazir_0-1631787501350.png

 

How can I get the previous period selected value in a card "test Previous"

here is the measure but showing me a blank value.

 

 

 

test previous = 
var minD2 = MIN(DateTable2[Date])
var maxD2 = MAX(DateTable2[Date])
var result =
    CALCULATE ( 
        SUM ( 'fact'[amount] )
        ,FILTER(
            'fact',
            [date] >= minD2 &&
            [date] <= maxD2
        )
        ,ALL(DateTable[Date])
        // ,ALL('fact')
    )
return result

 

 

 

The pbix file is too big can't attach it here. Need help in Dax only.

Please help me to fix this.

Thanks

 

1 ACCEPTED SOLUTION
adeelnazir
Helper I
Helper I

Here I go 😉

got the solution, sorry wrong filter was applied.

 

 

test previous = 
var minD2 = MIN(DateTable2[Date])
var maxD2 = MAX(DateTable2[Date])
var result =
    CALCULATE ( 
        SUM ( 'fact'[amount] )
        ,FILTER(
            ALL('DateTable'),
            [Date] >= minD2 &&
            [Date] <= maxD2
        )
    )
return result

 

 

 

View solution in original post

1 REPLY 1
adeelnazir
Helper I
Helper I

Here I go 😉

got the solution, sorry wrong filter was applied.

 

 

test previous = 
var minD2 = MIN(DateTable2[Date])
var maxD2 = MAX(DateTable2[Date])
var result =
    CALCULATE ( 
        SUM ( 'fact'[amount] )
        ,FILTER(
            ALL('DateTable'),
            [Date] >= minD2 &&
            [Date] <= maxD2
        )
    )
return result

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.