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.
Hi,
Friends, I need help with DAX formula.
What i have :
city | product # | date | pcs |
Beijing | 123544 | January 01 2019 | 1 |
Beijing | 123544 | January 01 2019 | 10 |
Beijing | 123544 | January 02 2019 | 15 |
Beijing | 123544 | January 02 2019 | 2 |
Shanghai | 123544 | January 01 2019 | 3 |
Shanghai | 123544 | January 01 2019 | 12 |
Shanghai | 123544 | January 02 2019 | 12 |
What i need is to make a measure which show only maximum results per day group by city, date and product pcs.
like this:
city | product | month | sum and maximum result per day (pcs) |
Beijing | 123544 | 201901 | 17 |
Shanghai | 123544 | 201901 | 15 |
Please help
Solved! Go to Solution.
hi, @Thoms
If you want to keep [date] field in the visual, just adjust the formula as below:
Measure 2 = var _table=CALCULATETABLE(SUMMARIZE('Table','Table'[city],'Table'[product #],'Table'[Month],'Table'[date],"_pcs",SUM('Table'[pcs])),ALL('Table'[date])) return MAXX(_table,[_pcs])
Result:
Best Regards,
Lin
HI, @Thoms
Just try this simple way as below:
Step1:
Create a month column for your date column
Month = YEAR('Table'[date])*100+MONTH('Table'[date])
Step2:
Use this formula to create a measure to get your requirement:
Measure = var _table=SUMMARIZE('Table','Table'[city],'Table'[product #],'Table'[Month],'Table'[date],"_pcs",SUM('Table'[pcs])) return MAXX(_table,[_pcs])
Result:
And here is pbix file, please try it.
Best Regards,
Lin
If i add the days, table do not shows the total of the month
hi, @Thoms
If you want to keep [date] field in the visual, just adjust the formula as below:
Measure 2 = var _table=CALCULATETABLE(SUMMARIZE('Table','Table'[city],'Table'[product #],'Table'[Month],'Table'[date],"_pcs",SUM('Table'[pcs])),ALL('Table'[date])) return MAXX(_table,[_pcs])
Result:
Best Regards,
Lin
Dear,
Thanks a lot! works perfect!
hi, @Thoms
You are welcome.
please accept the reply as solution, that way, other community members will easily find the solution when they get same issue.
best Regards,
lin
Hi,
Thankx for feedback! but how about if i need the column in the table, not measure?
Danno thanks,
Sorry, i might have put it purly.
Acctually ill be fine with a measure which will make a sum of sales of particular product per day and find max of those sales among days, to find when this product was selling better.
If you need help with measures let me know, otherwise please mark as solution
Yes, i need a measure.
You need a column for the Month (if you dont already have a separate calendar table), that will alow you to group by month in the format you require. The simple measures for max and total can be created as : Total pcs = SUM([pcs]) and Max pcs = MAX([pcs]) and providing that you split the result by month you will see the results in your table / matrix on the report.
Ok, ill try to explain in other way.
How do i add a new column in table (sumup per day and max in month by prod and city)?
city | product # | date | pcs | sumup per day | max in month by product and city |
Beijing | 123544 | January 01 2019 | 1 | 11 | 17 |
Beijing | 123544 | January 01 2019 | 10 | 11 | 17 |
Beijing | 123544 | January 02 2019 | 15 | 17 | 17 |
Beijing | 123544 | January 02 2019 | 2 | 17 | 17 |
Shanghai | 123544 | January 01 2019 | 3 | 15 | 15 |
Shanghai | 123544 | January 01 2019 | 12 | 15 | 15 |
Shanghai | 123544 | January 02 2019 | 12 | 12 | 15 |
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
99 | |
80 | |
70 | |
60 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |