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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
qwerttty
Helper I
Helper I

Find the difference between two dates value

Hi, 

I'm new in power bi. Wondering are there anyway to get the difference from the sum of month1 and sum of month 2. 

I use the measure: diff = [Sum of Month 2]-[Sum of Month 1]

I have edit the interactions of the filter, not sure is this the issue causing blank for the difference. 

Hope any can help me this issue. 

qwerttty_0-1691654768390.png

Thanks so much for the help. 

Kind regards. 

1 ACCEPTED SOLUTION

By reading that, this should be caused by the bidirectional relationship of the two calender tables.

 

Although this may be be optimal (since I don't know if it is essential for you to keep the relationship between the calender table and water flow monthly)I, I think you can remove the relationship between that two calender tables, and then create another calender table. This should make you having 3 calender tables.

 

And then use that 2 standalone calender table in your slicers and DAX.

Please see if that works.



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!

View solution in original post

10 REPLIES 10
qwerttty
Helper I
Helper I

Hi @johnyip 

The dax are 

Sum of Month 1 =
CALCULATE(
   [total incoming],
    FILTER(
        'Water Flow Monthly',
        MONTH('Water Flow Monthly'[Timestamp])=MONTH(MAX('Calendar'[Date]))
        && YEAR('Water Flow Monthly'[Timestamp])=year(MAX('Calendar'[Date]))
    )
)
and 
Sum of Month 2 =
CALCULATE(
   [total incoming],
    FILTER(
        'Water Flow Monthly',
        MONTH('Water Flow Monthly'[Timestamp])=MONTH(MAX('Calendar (2)'[Date]))
        && YEAR('Water Flow Monthly'[Timestamp])=year(MAX('Calendar (2)'[Date]))
    )
)
I'm using two exact calendar table, because one calendar table cannot give me the different

@qwerttty Can you show the relationships of the tables?



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!

Hi @johnyip ,

Here are the relationship table.

qwerttty_0-1691656015448.png

Thanks for your help. 

Kind regards. 

 

By reading that, this should be caused by the bidirectional relationship of the two calender tables.

 

Although this may be be optimal (since I don't know if it is essential for you to keep the relationship between the calender table and water flow monthly)I, I think you can remove the relationship between that two calender tables, and then create another calender table. This should make you having 3 calender tables.

 

And then use that 2 standalone calender table in your slicers and DAX.

Please see if that works.



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!

Hi @johnyip,

 

Thanks for your help after I create another calendar table. 

 

It works for me. 

 

Kind regards. 

Hi @johnyip ,

 

Thanks for your help. 

After standalone those calendar, I get a 0 for the difference, but it suppose be coming out value. Below are the relationship table

qwerttty_0-1691656773238.pngqwerttty_1-1691656787631.png

Thanks for your help. 

Kind regards. 

 

Kishore_KVN
Super User
Super User

Hello @qwerttty ,

To get difference between dates, use DATEDIFF DAX function and create your measure as per your need like to calculate DAYS/MONTHS/YEARS 

 

Dates Difference = DATEDIFF(Date1, Date2,Duration)

 

If this post helps, then please consider accepting it as the solution to help other members find it more quickly. Thank You!!

Hi @Kishore_KVN,

 

Thanks for the recommendation, 

however, I not need to get the different between two dates. 

I would like to get the amount from the selected date and find the difference of the amount between two selected date.

 

Thanks for your help. 

Kind regards. 

 

johnyip
Super User
Super User

What is the DAX of [Sum of Month 1] and [Sum of Month 2]?



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!

Hi @johnyip, 

Thanks for your help. 

The dax are 

Sum of Month 1 =
CALCULATE(
   [total incoming],
    FILTER(
        'Water Flow Monthly',
        MONTH('Water Flow Monthly'[Timestamp])=MONTH(MAX('Calendar'[Date]))
        && YEAR('Water Flow Monthly'[Timestamp])=year(MAX('Calendar'[Date]))
    )
)
and 
Sum of Month 2 =
CALCULATE(
   [total incoming],
    FILTER(
        'Water Flow Monthly',
        MONTH('Water Flow Monthly'[Timestamp])=MONTH(MAX('Calendar (2)'[Date]))
        && YEAR('Water Flow Monthly'[Timestamp])=year(MAX('Calendar (2)'[Date]))
    )
)
I'm using two exact calendar table, because one calendar table cannot give me the different.
 
Kind regards. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.