Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
devendrakotaru
Frequent Visitor

Trying for dax measure which gives the latest day sales in all columns

Hi All,

 

Attached are the tables, as an example of what I am trying to achieve.
If Wed sales are 630 then all columns should show as 630 irrespective of the column.

If Thu sales are 647 then all columns should show as 647 irrespective of the column.

 

MondayTuesdayWednesdayThursdayFriday
52860463000
63063063000

 

MondayTuesdayWednesdayThursdayFriday
5286046306470
6476476476470

 

Measure:

Sale =
VAR Totalv =
IF(SELECTEDVALUE('Fact'[Day Column])="Friday" && SUM('Fact'[Sales])>0,5,
IF(SELECTEDVALUE('Fact'[Day Column])="Thursday" && SUM('Fact'[Sales])>0,4,
IF(SELECTEDVALUE('Fact'[Day Column])="Wednesday" && SUM('Fact'[Sales])>0,3,
IF(SELECTEDVALUE('Fact'[Day Column])="Tuesday" && SUM('Fact'[Sales])>0,2,
IF(SELECTEDVALUE('Fact'[Day Column])="Monday" && SUM('Fact'[Sales])>0,1,0)))))

Var Sales = IF(ISBLANK(Totalv),0, CALCULATE(SUM('Fact'[Sales]),FILTER(Day_Column_Index,Day_Column_Index[Index]=Totalv)))
return
Sales

The above DAX is not working as expected, can someone can help me here?
 
2 ACCEPTED SOLUTIONS
v-tangjie-msft
Community Support
Community Support

Hi @devendrakotaru ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1677485086680.png

(2) We can create a measure. 

Measure = 
var _add=ADDCOLUMNS(ALL('Table'),"Index",SWITCH(TRUE(),[Day Column]="Monday",1,[Day Column]="Tuesday",2,[Day Column]="Wednesday",3,[Day Column]="Thursday",4,5))
var _find=MAXX(FILTER(_add,[Sales]<>0),[Index])
var _relatedvalue=MAXX(FILTER('Table',[Day Column]=MAX([Day Column])),[Sales])
return IF(_relatedvalue<>0,MAXX(FILTER(_add,[Index]=_find),[Sales]),0)

(3) Then the result is as follows.

vtangjiemsft_1-1677485254816.png

 

Best Regards,

Neeko Tang

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

BeaBF
Impactful Individual
Impactful Individual

@devendrakotaru 

 

Sale =
VAR SelectedDay = SELECTEDVALUE('Fact'[Day Column])
VAR TotalSales = CALCULATE(SUM('Fact'[Sales]), 'Fact'[Day Column] = SelectedDay)
RETURN
IF(TotalSales > 0, TotalSales, BLANK())

 

BBF

View solution in original post

2 REPLIES 2
BeaBF
Impactful Individual
Impactful Individual

@devendrakotaru 

 

Sale =
VAR SelectedDay = SELECTEDVALUE('Fact'[Day Column])
VAR TotalSales = CALCULATE(SUM('Fact'[Sales]), 'Fact'[Day Column] = SelectedDay)
RETURN
IF(TotalSales > 0, TotalSales, BLANK())

 

BBF

v-tangjie-msft
Community Support
Community Support

Hi @devendrakotaru ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1677485086680.png

(2) We can create a measure. 

Measure = 
var _add=ADDCOLUMNS(ALL('Table'),"Index",SWITCH(TRUE(),[Day Column]="Monday",1,[Day Column]="Tuesday",2,[Day Column]="Wednesday",3,[Day Column]="Thursday",4,5))
var _find=MAXX(FILTER(_add,[Sales]<>0),[Index])
var _relatedvalue=MAXX(FILTER('Table',[Day Column]=MAX([Day Column])),[Sales])
return IF(_relatedvalue<>0,MAXX(FILTER(_add,[Index]=_find),[Sales]),0)

(3) Then the result is as follows.

vtangjiemsft_1-1677485254816.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors