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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Calculating accurate sales data

Hi everyone, 

 

Happy Friday!

 

I have a table with a list of accounts. When someone selects an account datacards update to that particular account's information. 

 

If no data is selected on the table, I want the default display in the datacard to be "-" and not the first value. Can anyone help with this please? 

 

 

My second question is this: 

 

Company	Date	 Sales 
Fulham	01/01/2019	 52,402 
Fulham	02/01/2019	 20,521 
Fulham	03/01/2019	 54,548 
Fulham	04/01/2019	 40,041 
Fulham	05/01/2019	 51,340 
Fulham	06/01/2019	 48,950 
Fulham	07/01/2019	 35,430 
Fulham	08/01/2019	 26,909 
Fulham	09/01/2019	 47,437 
Fulham	10/01/2019	 34,887 
Fulham	11/01/2019	 51,005 
Fulham	12/01/2019	 36,178 
Fulham	01/01/2020	 22,112 
Fulham	01/03/2020	 40,004 
Fulham	01/06/2020	 39,168 

 

I want to calculate the YTD (2020) value of sales, but return "-" if nothing from the main table is selected or isblank. 

 

I want to take the start of the month from today's date and calculate last years equivalent 2019 sales (so from Jan to June of last year). Also returning "-" if nothing from the table is selected or isblank.

 

I have got completely stuck and would appreciate any help offered at all. 

 

Thank you

 

D

1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@Anonymous 

1. For the YTD you could try this following formula, if you only need Year 2020, you can add another year filter to the dax.

 

YTD measure  = CALCULATE(SUM('Table'[Sales]),DATESYTD('Table'[Date]))

 

2. To get "-" when no selected you could create a measure. For example, this measure uses Isfiltered() to determine whether the company is filtered.

 

Measure = IF(ISFILTERED('Table'[Company]),[YTD measure],"-")

 


Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
V-pazhen-msft
Community Support
Community Support

@Anonymous 

1. For the YTD you could try this following formula, if you only need Year 2020, you can add another year filter to the dax.

 

YTD measure  = CALCULATE(SUM('Table'[Sales]),DATESYTD('Table'[Date]))

 

2. To get "-" when no selected you could create a measure. For example, this measure uses Isfiltered() to determine whether the company is filtered.

 

Measure = IF(ISFILTERED('Table'[Company]),[YTD measure],"-")

 


Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Brilliant, thanks both! 

parry2k
Super User
Super User

@Anonymous you should HASONEFILTER function and check if a value is selected or not and based on that tweak your measure to return VALUE or '--'

 

As a best practice, add date dimension in your model and use it for and time intelligence calculations. Once the date dimension is added, mark it as a date table on table tools.

https://perytus.com/2020/05/22/create-a-basic-date-table-in-your-data-model-for-time-intelligence-calculations/

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.