cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper I
Helper I

Show current month&year when nothing selected on slicer

Hi Guysss! 

 

I need your help, I am exhausted. Situation like this:

I have a visual cost by year & month. I want to show cost of current year if nothing selected on slicer. Slicer from Datetable (DAX) and all tables has year and month column. 

I write this DAX but I couldnt do what I am wanted. 

 

Finans_TotalEmploeeCost _ Avg_ Value_Month = IF(ISCROSSFILTERED(Finans_TotalEmploeeCost[Year]),
CALCULATE(AVERAGE(Finans_TotalEmploeeCost[Value]),FILTER(Finans_TotalEmploeeCost, Finans_TotalEmploeeCost[Year] =ALLSELECTED('Date'[Year]))),
CALCULATE(AVERAGE(Finans_TotalEmploeeCost[Value]),Finans_TotalEmploeeCost[Year]=YEAR(TODAY()))
 

Datetable and thistable has 1-* relation. 

What I want:q1.pngScreenshot_13.png


With calculation(below) 

 

Screenshot_14.png

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

hi  @BirhanAYDS 

Just adjust the formula as below:

Finans_TotalEmploeeCost _ Avg_ Value_Month = IF(ISFILTERED('Finans_TotalEmploeeCost'[Year]),
CALCULATE(AVERAGE(Finans_TotalEmploeeCost[Value])),
CALCULATE(AVERAGE(Finans_TotalEmploeeCost[Value]),Finans_TotalEmploeeCost[Year]=YEAR(TODAY())))

 

If not your case, please share your sample pbix file and your expected output.

 

Regards,

Lin

Community Support Team _ Lin
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

2 REPLIES 2
Super User IV
Super User IV

@BirhanAYDS , You can use isfiletered do check weather the slicer has value or .

 

Now Year You have measures like

example

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
//Only year vs Year, not a level below


This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))

As you want Avg of the month get another measure distinctcount of month using same formula and divide

 

distinctcount (Table[Month Year])

or

distinctcount (Date[Month Year])

use year formula of top these

 

YTD Sales = CALCULATE(distinctcount (Date[Month Year]),DATESYTD('Date'[Date],"12/31"))



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Community Support
Community Support

hi  @BirhanAYDS 

Just adjust the formula as below:

Finans_TotalEmploeeCost _ Avg_ Value_Month = IF(ISFILTERED('Finans_TotalEmploeeCost'[Year]),
CALCULATE(AVERAGE(Finans_TotalEmploeeCost[Value])),
CALCULATE(AVERAGE(Finans_TotalEmploeeCost[Value]),Finans_TotalEmploeeCost[Year]=YEAR(TODAY())))

 

If not your case, please share your sample pbix file and your expected output.

 

Regards,

Lin

Community Support Team _ Lin
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

Helpful resources

Announcements
November Update

Check it Out!

Click here to read more about the November 2020 Updates!

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform October Community Highlights

Check out the top community contributors across all of the communities

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors