Forum Discussion
Count current week and previous week
- Anonymous3 years ago
Hi Jiangmei_wu ,
Create this measure.
Measure = var a=SUMMARIZE(ALLSELECTED(Sheet1),Sheet1[location],[Week number],[Date 1],"Current Week Count",[Current Week Count]) return MAXX(FILTER(a,[location] in VALUES(Sheet1[location])&&[Week number] in VALUES(Sheet1[Week number])),[Current Week Count])Measure 2 = SUMX(VALUES('Sheet1'[location]),[Measure])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.
- Anonymous3 years ago
Hi Jiangmei_wu ,
You just need to place [MEASURE] on the card visual object.
Best Regards,
Neeko Tang
Hi Jiangmei_wu ,
According to your description, here are my steps you can follow as a solution.
(1)My test data is the same as yours.
(2) We can create measures.
current week = COUNT('Table'[name])previous week = COUNTROWS(FILTER(ALLSELECTED('Table'),'Table'[Week number]=MAX('Table'[Week number])-1))
(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
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.
- Jiangmei_wu3 years agoFrequent Visitor
Hi Neeko,
Thanks for provide the solutions!
I have a version Power BI Desktop (May, 2022). The current week Dax works, but Previous Week Dax still gave me a blank in the card. I twicked a bit to
Previous Week Count = calculate(COUNT(Sheet1[Name]),filter(all(Sheet1), 'Sheet1'[Week number]=max(Sheet1[Week number])-1)) and It works. Under Power BI Desktop, yours works.Now I have a new issue. When I put eveything in a table, the previous week isn't correet using both Daxs. I also need help on Daily Highest Name in Current Week.How can I add the attachment for raw data and pbix?Thanks,Mei- Anonymous3 years agoNot applicable
Hi Jiangmei_wu ,
Update the measure.
measure1 = calculate(COUNT(Sheet1[Name]), filter(all(Sheet1), 'Sheet1'[location]=MAX('Sheet1'[location]) && 'Sheet1'[Week number]=max(Sheet1[Week number])-1))Previous Week Count = SUMX(SUMMARIZE('Sheet1','Sheet1'[location],'Sheet1'[Week number],"total",[measure1]),[total])Daily Highest Name Count in Current Week = MAXX(SUMMARIZE(ALL('Sheet1'),'Sheet1'[location],"count",[Current Week Count]),[Current Week Count])If the above one can't help you get the desired result, please provide your expected result with backend logic and special examples.
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.
- Jiangmei_wu3 years agoFrequent Visitor
Hi Neeco, thank you for your time and patient to help me! Now Previous Week Count is working properly. The daily highest count by location in current week didn't have the result I am looking for in the Table (in the card it is correct). Using Week number 11 as current week which is March 12, 2023 that week in Slicer. In Excel Pivot table, the highest number at Location1 is 3, at Location3 is 4. However, pbix shows 7 for both locations. Plesae see the screenshots below and file links.
- MeiJiang3 years agoRegular Visitor