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
RaulB
Frequent Visitor

Show YTD when category doesn't have values for the selected date

I have the next matrix with scrap type and stations and YTD and a single select slicer for the date. 

RaulB_0-1691738011916.png

 

When I choose the date I should see the YTD until the selected date, but if I don't have any value for Scrap or station in the selected date it shows 0 when it should show the YTD until that day. Here is the formula:

YTD =

CALCULATE(

    divide(

        Sum(

            'Scrap'[Scrap_Cost]

        ),

        sum(

            Cost[day_Cost]

        )

    )+0,

    DATESYTD(

        'Calendar'[Date]

    )

)

 

Here is the expected output and sample tables:

RaulB_1-1691738011868.png

 

 

Cost table

Dateday_Cost
8/6/2023 0:001751597
8/5/2023 0:001153887
8/4/2023 0:001690295
8/3/2023 0:001480194
8/2/2023 0:001532197
8/1/2023 0:001290290

 

Scrap table

ScrapTypeBookingAreaDateScrap_Cost
Scrap IIBuild8/6/2023 0:0016348
Scrap IICON Station8/6/2023 0:004714
Scrap IILVK Station8/6/2023 0:0023395
Scrap IIRM Station8/6/2023 0:00945
Scrap IISEA Station8/6/2023 0:0021341
Scrap IIIAG Station8/6/2023 0:0029606
Scrap IVAG8/6/2023 0:0017114
Scrap IVARY8/6/2023 0:0022933
Scrap IVLRA8/6/2023 0:0012294
Scrap IVLRATT8/6/2023 0:0028622
Scrap IVPLK8/6/2023 0:0027536
Scrap IIBuild8/5/2023 0:0029116
Scrap IICON Station8/5/2023 0:009183
Scrap IILVK Station8/5/2023 0:006852
Scrap IIRM Station8/5/2023 0:0022300
Scrap IISEA Station8/5/2023 0:0025686
Scrap IIIAG Station8/5/2023 0:0021714
Scrap IVAG8/5/2023 0:0023017
Scrap IVARY8/5/2023 0:0026533
Scrap IVLRA8/5/2023 0:0027034
Scrap IVLRATT8/5/2023 0:007410
Scrap IVPLK8/5/2023 0:008622
Scrap IIBuild8/4/2023 0:0015481
Scrap IICON Station8/4/2023 0:0023777
Scrap IIIALR StationB8/4/2023 0:0013958
Scrap IILVK Station8/4/2023 0:0015435
Scrap IISanolc Station8/4/2023 0:0011679
Scrap IISEA Station8/4/2023 0:002996
Scrap IIIAG Station8/4/2023 0:0011205
Scrap IVAG8/4/2023 0:0024462
Scrap IVARY8/4/2023 0:0013699
Scrap IVLRA8/4/2023 0:0010115
Scrap IVLRATT8/4/2023 0:0010510
Scrap IVPLK8/4/2023 0:0018054
Scrap IAerf Station8/3/2023 0:0011144
Scrap IIBuild8/3/2023 0:0027665
Scrap IICON Station8/3/2023 0:0020027
Scrap IIIALR Station_Compound8/3/2023 0:0013262
Scrap IIIALR StationB8/3/2023 0:002206
Scrap IILVK Station8/3/2023 0:007412
Scrap IISanolc Station8/3/2023 0:0014233
Scrap IISEA Station8/3/2023 0:0029416
Scrap IIIAG Station8/3/2023 0:007694
Scrap IV 8/3/2023 0:0013414
Scrap IVAG8/3/2023 0:00942
Scrap IVARY8/3/2023 0:0023843
Scrap IVLRA8/3/2023 0:0027939
Scrap IVLRATT8/3/2023 0:009346
Scrap IVPLK8/3/2023 0:008909
Scrap IAerf Station8/2/2023 0:007707
Scrap IIBuild8/2/2023 0:0027759
Scrap IICON Station8/2/2023 0:009761
Scrap IIIALR StationB8/2/2023 0:004608
Scrap IILVK Station8/2/2023 0:0020418
Scrap IIRM Station8/2/2023 0:0021033
Scrap IISanolc Station8/2/2023 0:0011488
Scrap IISEA Station8/2/2023 0:0025013
Scrap IIIAG Station8/2/2023 0:0026575
Scrap IVAG8/2/2023 0:0025686
Scrap IVARY8/2/2023 0:0016010
Scrap IVLRA8/2/2023 0:0026136
Scrap IVLRATT8/2/2023 0:009983
Scrap IVPLK8/2/2023 0:0025224
Scrap IAerf Station8/1/2023 0:003555
Scrap IIBuild8/1/2023 0:0029792
Scrap IICON Station8/1/2023 0:0024425
Scrap IIIALR Station_Compound8/1/2023 0:0021692
Scrap IIIALR StationB8/1/2023 0:0024237
Scrap IILVK Station8/1/2023 0:0012970
Scrap IIRM Station8/1/2023 0:009584
Scrap IISanolc Station8/1/2023 0:002031
Scrap IISEA Station8/1/2023 0:009789
Scrap IIIAG Station8/1/2023 0:0017708
Scrap IVAG8/1/2023 0:001433
Scrap IVARY8/1/2023 0:0027768
Scrap IVLRA8/1/2023 0:007986
Scrap IVLRATT8/1/2023 0:0029335
Scrap IVMIX8/1/2023 0:002766
Scrap IVPLK8/1/2023 0:006250

 

rel.PNG

 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @RaulB ,

According to your description, I create a sample by the data you provided, but it can return a correct value.

vyanjiangmsft_0-1691743648198.png

I attach my sample below for your reference. If you need more help, please feel free to contact me.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

5 REPLIES 5
v-yanjiang-msft
Community Support
Community Support

Hi @RaulB ,

According to your description, I create a sample by the data you provided, but it can return a correct value.

vyanjiangmsft_0-1691743648198.png

I attach my sample below for your reference. If you need more help, please feel free to contact me.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thank you

Mahesh0016
Super User
Super User

@RaulB is ok, but I can't Visualization how you EndOutPut Display.

Mahesh0016
Super User
Super User

Hey @RaulB, Please can you share your Expected output?

Scrap I should be 0.71% because that's what it is in the previous day, but it is 0.00%

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.