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.
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!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
99 | |
73 | |
72 | |
49 |
User | Count |
---|---|
145 | |
109 | |
109 | |
90 | |
64 |