The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
Thanks in advance for your help!
I want to show YTD/ LTM sales at Store level in a table, however, I am getting correct totals but some rows are missing.
Lets say I select week49, only the stores in week49 will show as individual rows but total will show correct number.
How can I show all the stores selling in YTD time period and not just the selected week? (Example below)
I have created a measure to calculate YTD as follows:
Solved! Go to Solution.
Thanks for the reply from DataNinja777 , please allow me to provide another insight:
Hi, @Dr_BB
I believe the reason only one row of data is displayed is due to the interaction between the slicer and your visualisation object. The slicer's data comes from the original data, so it directly filters the original data rather than the expected result.
Here is my solution:
My sample data is as follows:
1.Firstly, create the following calculation table. Ensure that there is no relationship established between this calculation table and the original table:
slicert = DISTINCT(ALLEXCEPT('SALES','SALES'[STORE],'SALES'[SALES]))
2.Secondly, use the newly created calculation table as the slicer:
3.Next, create the following measure:
test_ytd =
VAR yr =
SELECTEDVALUE ( 'slicert'[YEAR] )
VAR mn =
SELECTEDVALUE ( 'slicert'[MONTH] )
VAR wk =
SELECTEDVALUE ( 'slicert'[WEEK] )
VAR sales_ytd =
CALCULATE (
SUM ( 'SALES'[SALES] ),
FILTER (
ALLEXCEPT ( 'SALES', 'SALES'[STORE] ),
SALES[YEAR] = yr
&& SALES[WEEK] <= wk
&& SALES[MONTH] <= mn
)
)
RETURN
IF (
ISFILTERED ( 'slicert'[MONTH] ) && ISFILTERED ( 'slicert'[WEEK] )
&& ISFILTERED ( 'slicert'[YEAR] ),
sales_ytd,
SUM ( 'SALES'[SALES] )
)
4.Here's my final result, which I hope meets your requirements.
5.Below are posts similar to your issue that might be helpful to you:
Solved: Total Revenue YTD for ALL years - Microsoft Fabric Community
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for the reply from DataNinja777 , please allow me to provide another insight:
Hi, @Dr_BB
I believe the reason only one row of data is displayed is due to the interaction between the slicer and your visualisation object. The slicer's data comes from the original data, so it directly filters the original data rather than the expected result.
Here is my solution:
My sample data is as follows:
1.Firstly, create the following calculation table. Ensure that there is no relationship established between this calculation table and the original table:
slicert = DISTINCT(ALLEXCEPT('SALES','SALES'[STORE],'SALES'[SALES]))
2.Secondly, use the newly created calculation table as the slicer:
3.Next, create the following measure:
test_ytd =
VAR yr =
SELECTEDVALUE ( 'slicert'[YEAR] )
VAR mn =
SELECTEDVALUE ( 'slicert'[MONTH] )
VAR wk =
SELECTEDVALUE ( 'slicert'[WEEK] )
VAR sales_ytd =
CALCULATE (
SUM ( 'SALES'[SALES] ),
FILTER (
ALLEXCEPT ( 'SALES', 'SALES'[STORE] ),
SALES[YEAR] = yr
&& SALES[WEEK] <= wk
&& SALES[MONTH] <= mn
)
)
RETURN
IF (
ISFILTERED ( 'slicert'[MONTH] ) && ISFILTERED ( 'slicert'[WEEK] )
&& ISFILTERED ( 'slicert'[YEAR] ),
sales_ytd,
SUM ( 'SALES'[SALES] )
)
4.Here's my final result, which I hope meets your requirements.
5.Below are posts similar to your issue that might be helpful to you:
Solved: Total Revenue YTD for ALL years - Microsoft Fabric Community
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Thanks a lot for your answer!
It is working for me. Just a small change in Step1 :
@Dr_BB ,
To address your DAX question and show all stores with sales in the YTD time period (not just those active in the selected week), you can modify your approach by ensuring the filter context does not exclude stores that do not have sales in the selected week.
Here's an improved DAX formula to achieve this:
test_ytd =
VAR yr = SELECTEDVALUE(SALES[YEAR])
VAR wk = SELECTEDVALUE(SALES[WEEK])
RETURN
CALCULATE(
SUM(SALES[sales]),
ALL(SALES[WEEK]), // Ensures all weeks are considered
SALES[YEAR] = yr,
SALES[WEEK] <= wk
)
Explanation of the Changes:
This adjustment ensures that the table displays all stores that have contributed to YTD sales, even if they are not active in the currently selected week. Let me know if further clarifications or refinements are needed!
Best regards,
@DataNinja777
Thanks for the answer!
However, this solution is not working since the data is getting filtered because of the slicer interaction.
Thanks again
User | Count |
---|---|
25 | |
10 | |
8 | |
7 | |
6 |
User | Count |
---|---|
32 | |
12 | |
10 | |
10 | |
9 |