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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
AvanthaPeiris
Regular Visitor

Replicate D-1 to D-3 summary sales table in Power BI table visualization

I'm getting monthly sales through an MS fabric connector to Power BI. I need to show the total product-wise monthly sales and the past three days' daily sales(the dates are not necessarily consecutive) as D-1, D-2, and D-3 columns apart from the cumulative total for the month. Based on the sales team requirement, I might need to add more columns, thus we need to use a Table visual, not a Matrix
The attached Excel carries a sample date for April, and it carries the sample date and intended table view in the Power BI. 
One other thing, if the given product's sales are not there for the given D-1, D-2, and D-3 dates respective column should show as zero against the relevant product.
I tried to get support from both Chatgpt and Gimini but both failed to support me. I'm new to Power BI, thus I'm not good with DAX either.
Sample data

Activated_DateProductAmountDATA_LOADED_DATERank
17/04/2025 00:00A74339166.7817/04/2025 00:001
17/04/2025 00:00B582875017/04/2025 00:001
17/04/2025 00:00C1510000017/04/2025 00:001
17/04/2025 00:00E797000017/04/2025 00:001
16/04/2025 00:00A5035486517/04/2025 00:005
16/04/2025 00:00B7076018.2517/04/2025 00:005
16/04/2025 00:00C2310000017/04/2025 00:005
16/04/2025 00:00E150000017/04/2025 00:005
11/04/2025 00:00A7492466917/04/2025 00:009
11/04/2025 00:00B10610334.3817/04/2025 00:009
11/04/2025 00:00C2179000017/04/2025 00:009
11/04/2025 00:00E738500017/04/2025 00:009
10/04/2025 00:00A66585627.817/04/2025 00:0013
10/04/2025 00:00B2798779917/04/2025 00:0013
10/04/2025 00:00C1707500017/04/2025 00:0013
10/04/2025 00:00D384000017/04/2025 00:0013
10/04/2025 00:00E8895616.517/04/2025 00:0013
09/04/2025 00:00A65542583.0617/04/2025 00:0018
09/04/2025 00:00B24621881.6917/04/2025 00:0018
09/04/2025 00:00C28505429.6317/04/2025 00:0018
09/04/2025 00:00E4761026.3417/04/2025 00:0018
08/04/2025 00:00A59155509.1717/04/2025 00:0022
08/04/2025 00:00B19481774.9117/04/2025 00:0022
08/04/2025 00:00C1450000017/04/2025 00:0022
08/04/2025 00:00D226350017/04/2025 00:0022
08/04/2025 00:00E5215718.1317/04/2025 00:0022


Required view

ProductMonthly TotalD-1(17/04)D-2(16/04)D-3(11/04)
A         634,723,285.37       74,339,166.78     50,354,865.00       74,924,669.00
B         167,643,684.17         5,828,750.00       7,076,018.25       10,610,334.38
C         506,915,638.22       15,100,000.00     23,100,000.00       21,790,000.00
D           15,092,824.00                               -                              -                                 -  
E           48,917,360.97         7,970,000.00       1,500,000.00         7,385,000.00
      1,373,292,792.73     103,237,916.78     82,030,883.25     114,710,003.38

Kindly check and assist me in creating this visualisation in Power BI. If there are any references or sample projects are there please share them with me
Thank you in advance
Avantha

2 ACCEPTED SOLUTIONS
danextian
Super User
Super User

Hi @AvanthaPeiris 

 

Create the following measure to rank the dates:

Date Rank = 
RANKX (
    ALLSELECTED ( 'Table' ),
    CALCULATE ( MAX ( 'Table'[Activated_Date] ) ),
    ,
    DESC,
    DENSE
)

Rank 1 is the latest date in the current context.

danextian_0-1745053279076.png

Create this measure for D1 Sales.

D1 Sales = 
SUMX (
    FILTER (
        ADDCOLUMNS (
            SUMMARIZE ( ALLSELECTED ( 'Table' ), 'Table'[Activated_Date] ),
            "@rank", [Date Rank],
            "@sales", [Sales]
        ),
        [@rank] = 1
    ),
    [@sales]
)

Create two more measures for D2 and D3.

danextian_1-1745053429732.png

As to the monthly sales, add the sum of sales amount to the visual and filter to a specific month.

Please note that Power BI does not currently support dynamic measure names as in your expected output - D-1(17/04), etc. There are workarounds to make that appear so possible but will take a considerable amount of development time.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

v-pnaroju-msft
Community Support
Community Support

Hi AvanthaPeiris,

Thank you for your follow-up.

Based on my understanding, kindly consider the following approach which may help resolve the issue:

  1. Create a new Date Rank measure that filters the Activated_Date within the selected DATA_LOADED_DATE.
    Date Rank =
    VAR SelectedLoadDate = MAX('SalesData'[DATA_LOADED_DATE])
    RETURN
    RANKX(
    FILTER(ALL('SalesData'), 'SalesData'[DATA_LOADED_DATE] = SelectedLoadDate),
    'SalesData'[Activated_Date],
    ,
    DESC,
    DENSE
    )

  2. Create updated daily sales measures (D1, D2, D3) to calculate amounts based on the selected snapshot.
    D1 Sales =
    CALCULATE(
    SUM('SalesData'[Amount]),
    FILTER(
    ALL('SalesData'),
    [Date Rank] = 1 &&
    'SalesData'[DATA_LOADED_DATE] = MAX('SalesData'[DATA_LOADED_DATE])
    )
    )
    Repeat similarly for D2 Sales and D3 Sales by changing the condition to [Date Rank] = 2 and [Date Rank] = 3 respectively.

  3. Ensure the Monthly Sales measure is also filtered according to the selected snapshot.
    Monthly Sales =
    CALCULATE(
    SUM('SalesData'[Amount]),
    FILTER(
    ALL('SalesData'),
    'SalesData'[DATA_LOADED_DATE] = MAX('SalesData'[DATA_LOADED_DATE]) &&
    MONTH('SalesData'[Activated_Date]) = MONTH(TODAY()) &&
    YEAR('SalesData'[Activated_Date]) = YEAR(TODAY())
    )
    )

  4. Add Product, Monthly Sales, D1 Sales, D2 Sales, and D3 Sales to a Table visual. Additionally, include a slicer on DATA_LOADED_DATE with single selection enabled.
    This will ensure that the sales data updates dynamically based on the selected snapshot.

If you find this response helpful, kindly mark it as the accepted solution and provide kudos. This will assist other community members facing similar queries.

Thank you.

View solution in original post

10 REPLIES 10
v-pnaroju-msft
Community Support
Community Support

Hi AvanthaPeiris,

We are following up to see if your query has been resolved. Should you have identified a solution, we kindly request you to share it with the community to assist others facing similar issues.

If our response was helpful, please mark it as the accepted solution and provide kudos, as this helps the broader community.

Thank you.

v-pnaroju-msft
Community Support
Community Support

Hi AvanthaPeiris,

Thank you for your follow-up.

Based on my understanding, kindly consider the following approach which may help resolve the issue:

  1. Create a new Date Rank measure that filters the Activated_Date within the selected DATA_LOADED_DATE.
    Date Rank =
    VAR SelectedLoadDate = MAX('SalesData'[DATA_LOADED_DATE])
    RETURN
    RANKX(
    FILTER(ALL('SalesData'), 'SalesData'[DATA_LOADED_DATE] = SelectedLoadDate),
    'SalesData'[Activated_Date],
    ,
    DESC,
    DENSE
    )

  2. Create updated daily sales measures (D1, D2, D3) to calculate amounts based on the selected snapshot.
    D1 Sales =
    CALCULATE(
    SUM('SalesData'[Amount]),
    FILTER(
    ALL('SalesData'),
    [Date Rank] = 1 &&
    'SalesData'[DATA_LOADED_DATE] = MAX('SalesData'[DATA_LOADED_DATE])
    )
    )
    Repeat similarly for D2 Sales and D3 Sales by changing the condition to [Date Rank] = 2 and [Date Rank] = 3 respectively.

  3. Ensure the Monthly Sales measure is also filtered according to the selected snapshot.
    Monthly Sales =
    CALCULATE(
    SUM('SalesData'[Amount]),
    FILTER(
    ALL('SalesData'),
    'SalesData'[DATA_LOADED_DATE] = MAX('SalesData'[DATA_LOADED_DATE]) &&
    MONTH('SalesData'[Activated_Date]) = MONTH(TODAY()) &&
    YEAR('SalesData'[Activated_Date]) = YEAR(TODAY())
    )
    )

  4. Add Product, Monthly Sales, D1 Sales, D2 Sales, and D3 Sales to a Table visual. Additionally, include a slicer on DATA_LOADED_DATE with single selection enabled.
    This will ensure that the sales data updates dynamically based on the selected snapshot.

If you find this response helpful, kindly mark it as the accepted solution and provide kudos. This will assist other community members facing similar queries.

Thank you.

v-pnaroju-msft
Community Support
Community Support

Hi AvanthaPeiris,

We wanted to check in regarding your query, as we have not heard back from you. If you have resolved the issue, sharing the solution with the community would be greatly appreciated and could help others encountering similar challenges.

If you found our response useful, kindly mark it as the accepted solution and provide kudos to guide other members.

Thank you.

v-pnaroju-msft
Community Support
Community Support

Thank you, @danextianfor your response.

 

Hi @AvanthaPeiris,

 

We would like to check if the solution provided by @danextian has resolved your issue. If you have found an alternative approach, we encourage you to share it with the community to assist others facing similar challenges.

If you found the response helpful, please mark it as the accepted solution and add kudos. This recognition benefits other members seeking solutions to similar queries.

 

Thank you.

AvanthaPeiris
Regular Visitor

Hi,
Thanks a lot for the support given, and your solution resolves my main issue. However, there is another twist to the dataset where there is a daily snapshot created and added to the dataset, so the final dataset looks like this.

Activated_Date Product Amount DATA_LOADED_DATE
17/04/2025 00:00 A 74339166.78 17/04/2025 00:00
17/04/2025 00:00 B 5828750 17/04/2025 00:00
17/04/2025 00:00 C 15100000 17/04/2025 00:00
17/04/2025 00:00 E 7970000 17/04/2025 00:00
16/04/2025 00:00 A 50354865 17/04/2025 00:00
16/04/2025 00:00 B 7076018.25 17/04/2025 00:00
16/04/2025 00:00 C 23100000 17/04/2025 00:00
16/04/2025 00:00 E 1500000 17/04/2025 00:00
11/04/2025 00:00 A 74924669 17/04/2025 00:00
11/04/2025 00:00 B 10610334.38 17/04/2025 00:00
11/04/2025 00:00 C 21790000 17/04/2025 00:00
11/04/2025 00:00 E 7385000 17/04/2025 00:00
16/04/2025 00:00 A 50354865 16/04/2025 00:00
16/04/2025 00:00 B 7076018.25 16/04/2025 00:00
16/04/2025 00:00 C 23100000 16/04/2025 00:00
16/04/2025 00:00 E 1500000 16/04/2025 00:00
11/04/2025 00:00 A 74924669 16/04/2025 00:00
11/04/2025 00:00 B 10610334.38 16/04/2025 00:00
11/04/2025 00:00 C 21790000 16/04/2025 00:00
11/04/2025 00:00 E 7385000 16/04/2025 00:00
11/04/2025 00:00 A 74924669 15/04/2025 00:00
11/04/2025 00:00 B 10610334.38 15/04/2025 00:00
11/04/2025 00:00 C 21790000 15/04/2025 00:00
11/04/2025 00:00 E 7385000 15/04/2025 00:00
It contains a sequence of DATA_LOADED_DATES, and for the visualisation, we need to select the maximum one, and it needs to be done via a Slicer. I tried it with your solution, then it failed. Kindly assist me with this situation, too.

Thanks again

and for the visualisation, we need to select the maximum one, and it needs to be done via a Slicer. I tried it with your solution, then it failed. Kindly assist me with this situation, too.

 

You mean you select the max loaded date from a slicer or the formula should pick the max date automatically?





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Yes, there would be a slicer in the view which would select the loaded date, and based on the selection, it would be the maximum date we should consider. After that, activation date-wise and product-wise daily sales amounts are to be calculated.
Thank you!

AvanthaPeiris
Regular Visitor

Thank you! Your solution resolves my main issue. However, there is another twist to the dataset: a daily snapshot is created and added to it, so the final dataset looks like this.

Activated_Date Product Amount DATA_LOADED_DATE
17/04/2025 00:00 A 74339166.78 17/04/2025 00:00
17/04/2025 00:00 B 5828750 17/04/2025 00:00
17/04/2025 00:00 C 15100000 17/04/2025 00:00
17/04/2025 00:00 E 7970000 17/04/2025 00:00
16/04/2025 00:00 A 50354865 17/04/2025 00:00
16/04/2025 00:00 B 7076018.25 17/04/2025 00:00
16/04/2025 00:00 C 23100000 17/04/2025 00:00
16/04/2025 00:00 E 1500000 17/04/2025 00:00
11/04/2025 00:00 A 74924669 17/04/2025 00:00
11/04/2025 00:00 B 10610334.38 17/04/2025 00:00
11/04/2025 00:00 C 21790000 17/04/2025 00:00
11/04/2025 00:00 E 7385000 17/04/2025 00:00
16/04/2025 00:00 A 50354865 16/04/2025 00:00
16/04/2025 00:00 B 7076018.25 16/04/2025 00:00
16/04/2025 00:00 C 23100000 16/04/2025 00:00
16/04/2025 00:00 E 1500000 16/04/2025 00:00
11/04/2025 00:00 A 74924669 16/04/2025 00:00
11/04/2025 00:00 B 10610334.38 16/04/2025 00:00
11/04/2025 00:00 C 21790000 16/04/2025 00:00
11/04/2025 00:00 E 7385000 16/04/2025 00:00
11/04/2025 00:00 A 74924669 15/04/2025 00:00
11/04/2025 00:00 B 10610334.38 15/04/2025 00:00
11/04/2025 00:00 C 21790000 15/04/2025 00:00
11/04/2025 00:00 E 7385000 15/04/2025 00:00
It contains a sequence of DATA_LOADED_DATES, and for the visualisation, we need to select the maximum one, and it needs to be done via a Slicer. I tried it with your solution, then it failed. Kindly assist me with this situation, too.

Thanks again

Avantha

AvanthaPeiris
Regular Visitor

Thank you very much for the support;

danextian
Super User
Super User

Hi @AvanthaPeiris 

 

Create the following measure to rank the dates:

Date Rank = 
RANKX (
    ALLSELECTED ( 'Table' ),
    CALCULATE ( MAX ( 'Table'[Activated_Date] ) ),
    ,
    DESC,
    DENSE
)

Rank 1 is the latest date in the current context.

danextian_0-1745053279076.png

Create this measure for D1 Sales.

D1 Sales = 
SUMX (
    FILTER (
        ADDCOLUMNS (
            SUMMARIZE ( ALLSELECTED ( 'Table' ), 'Table'[Activated_Date] ),
            "@rank", [Date Rank],
            "@sales", [Sales]
        ),
        [@rank] = 1
    ),
    [@sales]
)

Create two more measures for D2 and D3.

danextian_1-1745053429732.png

As to the monthly sales, add the sum of sales amount to the visual and filter to a specific month.

Please note that Power BI does not currently support dynamic measure names as in your expected output - D-1(17/04), etc. There are workarounds to make that appear so possible but will take a considerable amount of development time.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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