Hi guys
I am new to DAX and I am having a bit of trouble getting a dax formula to show all products even though they haven't been sold for a particular month..
My data consists of one table and looks like this. (Month is a calculated column)
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Country[/TD]
[TD]Product[/TD]
[TD]Quantity[/TD]
[TD]Date[/TD]
[TD]Month[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P1[/TD]
[TD]4[/TD]
[TD]2014-1-1[/TD]
[TD]January[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P2[/TD]
[TD]3[/TD]
[TD]2014-1-1[/TD]
[TD]January[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P3[/TD]
[TD]2[/TD]
[TD]2014-2-1[/TD]
[TD]February[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P1[/TD]
[TD]4[/TD]
[TD]2014-2-1[/TD]
[TD]February[/TD]
[/TR]
[TR]
[TD]CAN[/TD]
[TD]P1[/TD]
[TD]2[/TD]
[TD]2014-1-1[/TD]
[TD]January[/TD]
[/TR]
[TR]
[TD]CAN[/TD]
[TD]P4[/TD]
[TD]3[/TD]
[TD]2014-1-1[/TD]
[TD]January[/TD]
[/TR]
[TR]
[TD]CAN[/TD]
[TD]P1[/TD]
[TD]2[/TD]
[TD]2014-1-1[/TD]
[TD]February[/TD]
[/TR]
</tbody>[/TABLE]
I have made a calculated field called YTD that calculates year-to-date SUMS for the different products.
I also have made a calculated field called sum, that calculates the sum of products sold for the context specified in the PivotTable.
In the resulting PivotTable i get this result, if i for instance make a slicer on february:
February:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Country[/TD]
[TD]Product[/TD]
[TD]SUM[/TD]
[TD]YTD[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P1[/TD]
[TD]4[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P3[/TD]
[TD]2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]CAN[/TD]
[TD]P1[/TD]
[TD]2[/TD]
[TD]4[/TD]
[/TR]
</tbody>[/TABLE]
However what i want is this (I have highlighted what is different):
February:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Country[/TD]
[TD]Product[/TD]
[TD]SUM[/TD]
[TD]YTD[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P1[/TD]
[TD]4[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P2[/TD]
[TD]0[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P3[/TD]
[TD]2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]CAN[/TD]
[TD]P1[/TD]
[TD]2[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]CAN[/TD]
[TD]P4[/TD]
[TD]0[/TD]
[TD]3[/TD]
[/TR]
</tbody>[/TABLE]
So when I have made a slicer on dates, and I choose for instance february it shows only the products sold in february. But i want i to show all the products that has YTD>0, and just put a 0 in the SUM for the products that hasen't been sold that month.
I know i could solve this by inserting rows in the data source with quantity 0 for the products that hasen't been sold in a month. But this seems like a bad hack - and since there a lots and lots of products this would result in many unnecessary rows...
I know how to solve it in SQL, but that is not an option here..I have tried to google it but havent found a solution to this in DAX.
Thank you for your help
I am new to DAX and I am having a bit of trouble getting a dax formula to show all products even though they haven't been sold for a particular month..
My data consists of one table and looks like this. (Month is a calculated column)
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Country[/TD]
[TD]Product[/TD]
[TD]Quantity[/TD]
[TD]Date[/TD]
[TD]Month[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P1[/TD]
[TD]4[/TD]
[TD]2014-1-1[/TD]
[TD]January[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P2[/TD]
[TD]3[/TD]
[TD]2014-1-1[/TD]
[TD]January[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P3[/TD]
[TD]2[/TD]
[TD]2014-2-1[/TD]
[TD]February[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P1[/TD]
[TD]4[/TD]
[TD]2014-2-1[/TD]
[TD]February[/TD]
[/TR]
[TR]
[TD]CAN[/TD]
[TD]P1[/TD]
[TD]2[/TD]
[TD]2014-1-1[/TD]
[TD]January[/TD]
[/TR]
[TR]
[TD]CAN[/TD]
[TD]P4[/TD]
[TD]3[/TD]
[TD]2014-1-1[/TD]
[TD]January[/TD]
[/TR]
[TR]
[TD]CAN[/TD]
[TD]P1[/TD]
[TD]2[/TD]
[TD]2014-1-1[/TD]
[TD]February[/TD]
[/TR]
</tbody>[/TABLE]
I have made a calculated field called YTD that calculates year-to-date SUMS for the different products.
I also have made a calculated field called sum, that calculates the sum of products sold for the context specified in the PivotTable.
In the resulting PivotTable i get this result, if i for instance make a slicer on february:
February:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Country[/TD]
[TD]Product[/TD]
[TD]SUM[/TD]
[TD]YTD[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P1[/TD]
[TD]4[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P3[/TD]
[TD]2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]CAN[/TD]
[TD]P1[/TD]
[TD]2[/TD]
[TD]4[/TD]
[/TR]
</tbody>[/TABLE]
However what i want is this (I have highlighted what is different):
February:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Country[/TD]
[TD]Product[/TD]
[TD]SUM[/TD]
[TD]YTD[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P1[/TD]
[TD]4[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P2[/TD]
[TD]0[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]GB[/TD]
[TD]P3[/TD]
[TD]2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]CAN[/TD]
[TD]P1[/TD]
[TD]2[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]CAN[/TD]
[TD]P4[/TD]
[TD]0[/TD]
[TD]3[/TD]
[/TR]
</tbody>[/TABLE]
So when I have made a slicer on dates, and I choose for instance february it shows only the products sold in february. But i want i to show all the products that has YTD>0, and just put a 0 in the SUM for the products that hasen't been sold that month.
I know i could solve this by inserting rows in the data source with quantity 0 for the products that hasen't been sold in a month. But this seems like a bad hack - and since there a lots and lots of products this would result in many unnecessary rows...
I know how to solve it in SQL, but that is not an option here..I have tried to google it but havent found a solution to this in DAX.
Thank you for your help