Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Switch condition issue in DAX

Hello All,

 

I have report where I am showing sales and for each date.

My data is like below

 

TrendType      Date                Sales

Daily12/8/2022    100
Daily12/9/2022     100
Daily12/10/2022     90
Daily12/11/2022    250
Daily12/12/2022     210
Daily12/13/2022    450
Daily12/14/2022     80
Daily12/15/2022    70
Daily12/16/2022    290
Daily12/17/2022    600
Daily12/18/2022   700
Daily12/19/2022    50
Monthly11/1/2022   450
Monthly10/1/2022   600
Monthly9/1/2022    700
Monthly8/1/2022300
Monthly7/1/2022100
Monthly6/1/2022180
Monthly5/1/2022650
Monthly4/1/2022800
Monthly3/1/2022260
Monthly2/1/2022170
Monthly1/1/2022760
Monthly12/1/2021150

 

I created a sles KPI which will show like below.

 

KPI_Sales = SWITCH(TRUE(),
sum(Sheet1[Sales]) <=1000, 5,
sum(Sheet1[Sales]) <=600, 4,
sum(Sheet1[Sales])  <=300, 3,
sum(Sheet1[Sales]) <=200, 2,
1)


//if sum of sales <= 200 then 2
//if sum of sales >200 and lessthan equal to 300 then 3
//if sum of sales >300 and lessthan equal to 600 then 4
//if sum of sales >600 and lessthan equal to 1000  then 5
 
 

But when I show the kpi for each date I am not getting accurate results.

For all sales the kpi is showing 5.

 

Am I doing anything wrong here.

Please suggest

 

 

 

  • Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!

3 Replies