DAX - Items with no data

potap

New Member
Joined
Sep 5, 2014
Messages
43
Once again, I am stuck on something and ask for your help!

I got this measure :

Code:
=CALCULATE (
    SUM ( Sales[Sales] );
    Calender[isPast3Years] = TRUE ()
)

I have this pivot table that shows total sales by month :

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]2013[/TD]
[TD]2014[/TD]
[TD]2015[/TD]
[/TR]
[TR]
[TD]01[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]02[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]03[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]04[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]850[/TD]
[/TR]
[TR]
[TD]05[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]06[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]07[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]08[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]09[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Right now, the 2012 colomn doesn't appear because of the isPast3Years in the Calculate but I do have transactions in the Sales table. I don't have any transaction in May 2015 and in the following months, obviously.

If I drag this measure instead :

Code:
=IF ( ISBLANK ( [TotalSales] ); 0; [TotalSales] )



[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]2012[/TD]
[TD]2013[/TD]
[TD]2014[/TD]
[TD]2015[/TD]
[/TR]
[TR]
[TD]01[/TD]
[TD]0[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]02[/TD]
[TD]0[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]03[/TD]
[TD]0[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]04[/TD]
[TD]0[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]850[/TD]
[/TR]
[TR]
[TD]05[/TD]
[TD]0[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]06[/TD]
[TD]0[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]07[/TD]
[TD]0[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]08[/TD]
[TD]0[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]09[/TD]
[TD]0[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]0[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]0[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]0[/TD]
[TD]1000[/TD]
[TD]1000[/TD]
[TD]0[/TD]
[/TR]
</tbody>[/TABLE]

What I am looking for is a measure that gives 0 for every blank months in 2015 but not for 2012. I don't want to see any year that is not in the past 3. Tried Countrows() and other stuff but I wasn't able to figure something out :mad:

Thank you!!!
 
= IF (COUNTROWS(FILTER(Calendar, Calendar[IsPast3Years])) > 0, 0, BLANK()) +
SUM(Sales[Sales])

Look at the current context for rows in the past 3 years... if there are any... add a 0 to your measure.

Should work and perform well, but still feels a bit weird to me. <shrug>. Back to my coffee... :)

This is working!

This is too :

Code:
=IF (
    COUNTROWS ( FILTER ( Calendar, Calendar[IsPast3Years] ) )
        > 0,
    0 + SUM ( Sales[Sales] ),
    BLANK ()
)



</shrug>
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,224,091
Messages
6,176,294
Members
452,719
Latest member
Boonchai Charoenek

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top