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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX for plotting Recurrence of recently ordered customers on Stacked bar chart

Hi Guys,

 

I have just started my journey with PowerBi. Stuck with a scenario where i have to plot customers for selected month on stacked bar chart and their earlier order months(months will be on or before selected month) on legend and sorting the customers based on number of order months in descending order. 

CustomerOrderMonthIsOrderPlaced
Customer1Jan-191
Customer1Feb-191
Customer1Mar-191
Customer2Jan-191
Customer2Mar-191
Customer3Mar-191
Customer3Feb-191
Customer3Dec-191
Customer4Mar-191
Customer4Feb-191

 

1.If User selects Feb-19, charts shall display custmers who placed order in Feb-19 and their earlier order months as legend.

2.Sorting of customers shall be based on order months count till selected date

 

I tried below DAX expression with saperate table for slicer month. 
CALCULATE(SUM(Order[IsOrderPlaced]),FILTER(ALLSELECTED(Order[OrderMonth]),Order[OrderMonth]=MAx(Slicer[SlicerAnalysisMonth])))

 

The above dax expression is displying selected month customers but the legend is diplaying future values too. Sorting order is also not woring.

 

Any help would be  highly appricited.

 

Thanks in Advance.

 

Regards,

Hari

 

3 REPLIES 3
amitchandak
Super User
Super User

Are you looking for cumulative, In case you have the date you can get that easily with the help of the date table,

 

Or try to convert month into a date

Date = "1-"& Table[Month-year] //in format MMM-YYYY .And change the datatype to date.

 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(date,date[date] <=maxx(date,date[date])))

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

Anonymous
Not applicable

@amitchandak , Thanks for your reply. It is not working for me.

I am tryining to display selected month customer's historical orders by month.

For exapmle if user slects Dec-2019, DAX expression shoud return Costomers who ordered in Dec-2019 and their previous order months. My dimensions are Customer and OrderMonth.

 

I tried ALL() and AllSelected() but no luck.

 

Thanks,

Hari

Convert your month to date that would be better. Even to make the best use of all, you have to create an order month dimension. Then you all will work better.

 

Date = "01"-Table[Month-Year] //looking at the current format and then mark it as the date. Or try marking the current month as the date it will convert to date

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.