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
kagy100
Advocate II
Advocate II

Dax Assistance Required with Measure

Hi Team,

 

I needed your kind assistance with the below . .. 

The .pbix file can be found here 

 

question.JPG

 

 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hey, @kagy100

According to your description, I created data to reproduce your scenario. The pbix file is attached at the end.

Table A:

c1.png

Table B:

c2.png

There's a relationship between tables. You can create measures as follows.

Start Month = 
FORMAT(
    CALCULATE(
        MAX('Table A'[Date]),
        FILTER(
            ALL('Table A'),
            [Date]<=MAX('Table B'[Motor Enhancement Date])
        )
    ),
    "mmm-yy"
)
End Month = 
FORMAT(
    CALCULATE(
        MIN('Table A'[Date]),
        FILTER(
            ALL('Table A'),
            [Date]>MAX('Table B'[Motor Enhancement Date])
        )
    ),
    "mmm-yy"
)
Start Month Value = 
var startdate = 
CALCULATE(
        MAX('Table A'[Date]),
        FILTER(
            ALL('Table A'),
            [Date]<=MAX('Table B'[Motor Enhancement Date])
        )
)
return
CALCULATE(
    SUM('Table A'[Motor Value]),
    FILTER(
        ALL('Table A'),
        [Date]<=startdate
    )
)
End Month Value = 
var enddate = 
CALCULATE(
        MIN('Table A'[Date]),
        FILTER(
            ALL('Table A'),
            [Date]>MAX('Table B'[Motor Enhancement Date])
        )
)
return
CALCULATE(
    SUM('Table A'[Motor Value]),
    FILTER(
        ALL('Table A'),
        [Date]>=enddate
    )
)

Result:

c3.png

Best regards

Allan

If this post helps, then consider Accepting it as the solution to help other members find it faster.

View solution in original post

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hey, @kagy100

According to your description, I created data to reproduce your scenario. The pbix file is attached at the end.

Table A:

c1.png

Table B:

c2.png

There's a relationship between tables. You can create measures as follows.

Start Month = 
FORMAT(
    CALCULATE(
        MAX('Table A'[Date]),
        FILTER(
            ALL('Table A'),
            [Date]<=MAX('Table B'[Motor Enhancement Date])
        )
    ),
    "mmm-yy"
)
End Month = 
FORMAT(
    CALCULATE(
        MIN('Table A'[Date]),
        FILTER(
            ALL('Table A'),
            [Date]>MAX('Table B'[Motor Enhancement Date])
        )
    ),
    "mmm-yy"
)
Start Month Value = 
var startdate = 
CALCULATE(
        MAX('Table A'[Date]),
        FILTER(
            ALL('Table A'),
            [Date]<=MAX('Table B'[Motor Enhancement Date])
        )
)
return
CALCULATE(
    SUM('Table A'[Motor Value]),
    FILTER(
        ALL('Table A'),
        [Date]<=startdate
    )
)
End Month Value = 
var enddate = 
CALCULATE(
        MIN('Table A'[Date]),
        FILTER(
            ALL('Table A'),
            [Date]>MAX('Table B'[Motor Enhancement Date])
        )
)
return
CALCULATE(
    SUM('Table A'[Motor Value]),
    FILTER(
        ALL('Table A'),
        [Date]>=enddate
    )
)

Result:

c3.png

Best regards

Allan

If this post helps, then consider Accepting it as the solution to help other members find it faster.

Thank You @v-alq-msft for the kind assistance. 🙂

TomMartens
Super User
Super User

Hey @kagy100 ,

 

please consider creating a pbix file that contains the sample data from above. Upload the pbix to onedrive or dropbox and share the link.

 

I'm not sure what you have, meaning what data is available and what data needs to be calculated. I'm also wondering if a relationship between both tables can be established.

 

Regards,

Tom 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thanks for replying Tom,

 

The .pbix file can be found here: Usage Example 

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.