March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
the point is that I want to calculate the sum of sales for the current month and see the result from the year before
input data:
devFactSprzedaz[Data] - column with date
devFactSprzedaz[Sprzedaż netto] - sales column
devDimArtykul[Nazwa Magazynu] - column with stores list used for filtering specific stores
so I have two measures. The first one to calculate the sales value for the current month and this one work well all the time:
MTD = TOTALMTD(SUM(devFactSprzedaz[Sprzedaż netto]),devFactSprzedaz[Data])
and another to calculate same but year ago:
MTD LY = CALCULATE(TOTALMTD(SUM('devFactSprzedaz'[Sprzedaż netto]),'devFactSprzedaz'[Data]),SAMEPERIODLASTYEAR('devFactSprzedaz'[Data]))
without any filters, everything works ok !
the problem is when applied filters using devDimArtykul[Nazwa Magazynu] in right pane:
if I choose some stores from the list. the value of my second measure displays such an error:
Solved! Go to Solution.
Hi @luke050,
You need to create a date table, and use the date table in the [MTD LY] measure. Time intelligence calculations should be based on a date table.
Proud to be a Super User!
Ok so i created Date Table:
now the error does not appear, but the output for my MTD LY is incorrect, I get too large amount. and I don't know where it comes from because the measure looks ok
updated Measure:
MTD LY = CALCULATE(TOTALMTD(SUM('devFactSprzedaz'[Sprzedaż netto]),'devFactSprzedaz'[Data]),SAMEPERIODLASTYEAR(DateKey[Date]))
as far as I know it should work even if I use a smart date and then I don't need this date table but the result is the same:
Smart Date Measure
MTD LY = CALCULATE(TOTALMTD(SUM('devFactSprzedaz'[Sprzedaż netto]),'devFactSprzedaz'[Data]),SAMEPERIODLASTYEAR('devFactSprzedaz'[Data].[Date]))
in both cases my measure returns 12.72M and it show sum for period 2020-12-01 to 2020-12-31 but why??
also I calculated desired period manually and it should be : 3.94M
where am i making a mistake ?
Hi @luke050
Some Time Intelligence functions expect a continuous distinct date column to work with. A common and recommended practice is to use a Date table. Refer to below links to understand more about date table and modify your model accordingly.
https://radacad.com/do-you-need-a-date-dimension
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
Regards,
Community Support Team _ Jing Zhang
Hi @luke050 , @DataInsights ,
Also, to use Time Intelligence functions the date table must be contiguous and cover the whole period that you are calculating.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Proud to be a Super User!
Hi @luke050,
You need to create a date table, and use the date table in the [MTD LY] measure. Time intelligence calculations should be based on a date table.
Proud to be a Super User!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
134 | |
91 | |
89 | |
64 | |
58 |
User | Count |
---|---|
201 | |
137 | |
107 | |
72 | |
68 |