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

Append table with column from calculateTable.

I have the following table. I want use it to calculate the difference between the revenue of a given date, and that same date but one year ago, as to eventually create a visual in which I compare the revenue of Aug 2022 to Aug 2021, for instance.

robertvdleeuw_0-1662037153227.png

 

I have the following DAX expression for this:

    Revenue Growth =
    VAR prevDate = DATEADD('Growth Metrics'[Date], -1, YEAR)
    VAR diff =
        SELECTCOLUMNS(
            CALCULATETABLE('Growth Metrics', 'Growth Metrics'[Date] = prevDate),
            "Date", 'Growth Metrics'[Date],
            "Revenue Growth", 'Growth Metrics'[Revenue] - [Revenue])
    RETURN
        diff['Revenue Growth']

The problem is that I cannot access 'Revenue Growth' from diff like this. How can I append the existing table with this column?
Date is added in there because I tried using LOOKUPVALUE(), but to no avail.
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@robertvdleeuw , with help from date table you can have measure like

 

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))

 

diff = SUM(Sales[Sales Amount]) - [Year behind Sales]

 

Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@robertvdleeuw , with help from date table you can have measure like

 

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))

 

diff = SUM(Sales[Sales Amount]) - [Year behind Sales]

 

Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hey, thanks for the help. The measure seems to be working reporting the right data, (essentially all sales - all of the most recent year). However, the measure reverts to (BLANK) once I try to select a daterange using a slicer.


Perhaps I should've made my goal a bit clearer. I currently have the table below to show changes in revenue each month and year, but I want to change this to revenue growth in comparison to last year. 

robertvdleeuw_0-1662049955341.png

Is there a way to get this done using this measure? Right now, using the measure shows this:

robertvdleeuw_1-1662050048247.png

 

 

Nevermind, I didn't have any type of link established between 2 date columns in separate tables. The measure works perfectly now!

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!

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.