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 following measure is not working in powerbi desktop.
3 Months Unit Sold = CALCULATE([Units Sold],DATESINPERIOD(DimDate[FullDateAlternateKey],LASTDATE(DimDate[FullDateAlternateKey]),-3,MONTH))
When the same measure is created in Excel 2016 powerpivot it works.
Is this a bug?
Solved! Go to Solution.
Hi,
Here are the changes i made
=CALCULATE([Units Sold],DATESINPERIOD(DimDate[FullDateAlternateKey],LASTDATE(DimDate[FullDateAlternateKey]),-3,MONTH))
The correct result is shown below
Hi,
The third last column in your FaceInternetSales table is a proper date. The relationship should be from that column to the FullDateAlternateKey column of the DimDate column table.
@Anonymous,
Please elaborate. You may check the relationship and take a look at this link.
Thanks for the response. Relationships are ok and measures in powerbi and excel exactly the same accessing the same database. See images below. 3 Months Unit Sold is the measure in question
From powerbi
From Excel
Sorry, correct Excel table
@Anonymous,
It would be better to share us the simplified .pbix file. Make sure it is a measure, not calculated column.
Sorry just seeing this. How do I attach a file? I don't see any upload buttons. Using MS Edge
Regards
Hi @Anonymous,
You will have to upload the file to some file hosting servive and then share the download link here.
Hi,
Here are the changes i made
=CALCULATE([Units Sold],DATESINPERIOD(DimDate[FullDateAlternateKey],LASTDATE(DimDate[FullDateAlternateKey]),-3,MONTH))
The correct result is shown below
Thanks for your effort and time. Sorry about the late response.
Regards
Hi, I just tried your suggestion and it does not work. To begin, the relationship you suggested cannot work as the duedatekey in the sales table is an integer and the fulldatealternatekey in the date table is a date field. When I created this relationship the resulting table is empty.
I am using powerbi ver 2.50.4859.782 64-bit (September 2017). What version are you using? Remember I indicated that when I used excel with the same sql 2016 adventureworks DW it works correctly by copying and pasting the measure. This suggests a bug in the version I am using or a problem with my installation running on windows 10 pro.
Regards
Hi,
The third last column in your FaceInternetSales table is a proper date. The relationship should be from that column to the FullDateAlternateKey column of the DimDate column table.
Thanks again. I finally realized that because in power bi you don't have the facility to designate a date table then relationships must be based on date fields for the time intelligence functions to work. A work around I found on the internet proposed by Raz is to add the all(dimdate) at the end of the function and that works as well.
You are welcome.
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 |
---|---|
124 | |
87 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |