Forum Discussion
pbiforum123
6 years agoPost Patron
Help required in Switch statement
Since the first statement for "Total Sales" consists of the dates rest of the statement is not executed. If I remove the first statement which is "Total Sales" rest of the statement is executed. Wha...
Anonymous
6 years agoNot applicable
pbiforum123
6 years agoPost Patron
Since it has confidential data it cannot be shared. Sorry!
- Anonymous6 years agoNot applicable
Hi pbiforum123 ,
Yeah, I understood no problem.
I just gave some sample records and use the below dax for your request.Date_Group =SWITCH (TRUE (),Sample[Date] >= date(2019,9,1)&& Sample[Date] <= date(2019,9,30), "SampleOlderThanThisMonth",Sample[Date] >= date(2019,9,30)&& Sample[Date] <= date(2019,10,31), "SampleThisMonth",Sample[Date] >= date(2019,10,31)&& Sample[Date] <= date(2019,11,30), "SampleNextMonth",Sample[Date] >= date(2019,11,30)&& Sample[Date] <= date(2900,12,31), "SampleFuture",Sample[Date] >= date(1900,1,1)&& Sample[Date] <= date(2900,12,31), "Total Sample")Output:Best Regards,
Mail2inba4
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- pbiforum1236 years agoPost Patron
Thanks but you have passed wrong date here hence it was working...
Sample[Date] >= date(2019,9,1)&& Sample[Date] <= date(2019,9,30), "SampleOlderThanThisMonth",It should have date(1900,1,1)...- pbiforum1236 years agoPost Patron
As a quick fix I renamed the "Subtotal" to "Total Sales" 🙂
Only concern is I am not able to bring it to the top though I select Top in the subtotal settings.