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
sambou
Frequent Visitor

How to compare two date columns on the same chart

Hi There,

 

is there a way to create a chart/table in Power BI similar to the table below? to compare the revenue from two different weeks on the same table? I’m trying to pull data from SQL Server and compare the revenue of prior week (column 8/25/2017) to current week revenue (column 8/31/2017) then create a calculated measure as the last column (Difference). I can’t figure out how to have two date columns on a Power BI table or chart similar to columns below.

 

Region

8/25/20178/31/207Difference
North American entities        15,000,000          16,700,000            1,700,000
Canadian entities        19,475,000          23,000,000            3,525,000
Latin American entities          8,000,000            5,900,000          (2,100,000)
Japanese entities          9,100,000          11,000,000            1,900,000
Australian entities          5,000,000            4,700,000             (300,000)
United Kingdom entities        13,000,000          11,400,000          (1,600,000)
Rest of Europe entities        17,000,000          18,000,000            1,000,000
Company Total       86,575,000          90,700,000            4,125,000

 

thanks,

 

Sam

1 ACCEPTED SOLUTION
v-sihou-msft
Employee
Employee

@sambou

 

We can create a measure to get the difference of two selected dates.

 

Difference =
CALCULATE (
    SUM ( Table1[Value] ),
    FILTER ( ALLSELECTED ( Table1[Date] ), Table1[Date] = MAX ( Table1[Date] ) )
)
    - CALCULATE (
        SUM ( Table1[Value] ),
        FILTER ( ALLSELECTED ( Table1[Date] ), Table1[Date] = MIN ( Table1[Date] ) )
    )

However, We can't have this measure appeared on Grand Total level only. It will always appear under each column group. 

 

55.PNG

 

So I suggest you create another table visual, and bring Region field and Difference measure only. 

 

Regards,

View solution in original post

2 REPLIES 2
v-sihou-msft
Employee
Employee

@sambou

 

We can create a measure to get the difference of two selected dates.

 

Difference =
CALCULATE (
    SUM ( Table1[Value] ),
    FILTER ( ALLSELECTED ( Table1[Date] ), Table1[Date] = MAX ( Table1[Date] ) )
)
    - CALCULATE (
        SUM ( Table1[Value] ),
        FILTER ( ALLSELECTED ( Table1[Date] ), Table1[Date] = MIN ( Table1[Date] ) )
    )

However, We can't have this measure appeared on Grand Total level only. It will always appear under each column group. 

 

55.PNG

 

So I suggest you create another table visual, and bring Region field and Difference measure only. 

 

Regards,

Hi Simon,

 

the measure did not work, It didn't create two column dates. How did you add the spelled out date on the top of column header? did you specify dates in the mesure? from the Revenue table I selected the highlighted columns below.

 

Difference =

CALCULATE (

   SUM ( Revenue[Revenue in USD] ),

   FILTER ( ALLSELECTED ( Revenue[As of Date] ), Revenue[As of Date] = MAX ( Revenue[As of Date] ) ))

 

   - CALCULATE (

       SUM ( Revenue[Revenue in USD] ),

       FILTER ( ALLSELECTED ( Revenue[As of Date] ), Revenue[As of Date] = MIN ( Revenue[As of Date] ) )  )

 

Thanks,

 

Sam

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.