Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Create sales measure based on date table

Hey everyone, 

 

I tried to look up in the community but haven't found anything this specific.

 

I have two tables: 

 

1. Sales Table- including 2 columns: Full date & Amount[USD]

 

2. Date Table - including 4 columns: full date, the day of the week, FY, Quarter. 

 

I am trying to create a total revenues measure based on the filtered date-table in a way that when I use slicer (for example a specific month) it will calculate other measures based on the total revenues one.

 

I tried using this formula:

 

New_Total_Revenues = CALCULATE(
SUM('Sales'[Amount]),
FILTER(ALL('Date Dim'[Date]),
DATESBETWEEN('Date Dim'[Date],FIRSTDATE('Date Dim'[Date]),LASTDATE('Date Dim'[Date]))))
 
However, I get the following error:
 
"MdxScript(Model) (162,14) Calculation error in measure: A table of multiple values was supplied where a single value was expected"
 
I am having a tough time with this. I am trying to create a dynamic total revenue measure since later on I will use it to create  12/6/3 months sales averages and FYTD average measures which I would like to be able to use slicer to get dynamic and accurate results when I choose any month.
 
Thanks in advance for the help, and if I am missing something here and a normal total revenue measure such as SUM('Sales'[Amount]) still will give me the same result then I would like to know why, because if I choose a certain month all of the date-table will be decreased to the specific month and I am afraid it will exclude sales which need to be included.
 
All the best!
1 REPLY 1
parry2k
Super User
Super User

@Anonymous this is the fix but I think you are over complicating things.

 

New_Total_Revenues = CALCULATE(
SUM('Sales'[Amount]),
DATESBETWEEN('Date Dim'[Date],FIRSTDATE('Date Dim'[Date]),LASTDATE('Date Dim'[Date]) )
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.