Forum Discussion

nates05's avatar
nates05
Frequent Visitor
6 years ago

DAX to M language

Hi, 

 

Is there an M code equivalent for the DAX queries below? The following DAX formulas calculates items sold per period and per unique item. The raw sales data that I have is a running total per period. Please see screenshots below of the sample data.

 

Rank = RANKX ( 'Table', 'Table'[Period],, ASC, DENSE )
Sold per period =
VAR a =
CALCULATE (
FIRSTNONBLANK ( 'Table'[Total Sold], 1 ),
FILTER (
'Total Sold',
'Total Sold'[Serial Codes] = EARLIER ( 'Table'[Serial Codes] )
&& 'Table'[Rank]
= EARLIER ( 'Table'[Rank] ) - 1
)
)
RETURN
'Table[Total Sold] - a
 

1 Reply

  • v-piga-msft's avatar
    v-piga-msft
    Resident Rockstar

    Hi nates05 ,

    From your formulas, it seems that you have more than more tables.

    Do you have the two tablses for  'Table' and 'Total Sold'?

    If it is convenient, could you share the complete data sample as table format so that we could have a test on it?

    In addition, ImkeF do you have any ideas?

    Best Regards,

    Cherry