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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
onedayover
Helper III
Helper III

Replacing blanks with previous count in continuous line chart

Hi All

I'm hoping someone will be able to help me modify this measure. I've tried a number of ways to make it work but can't quite seem to get it right. Where there is a blank week (Wk 9 in this example, I would like the figure from the previous week, e.g. 100 (Wk 8), so that my line is continuous and doesn't drop to 0. My measure so far is:

 

2024_cate_tickets =
COUNTROWS (
FILTER (
ALL ( 'cate' ),
'cate'[week_num] <= MAX ( 'cate'[week_num] )
&& 'cate'[date_registered] <= MAX ( 'cate'[date_registered] )
&& 'cate'[event] = "cate 2024"
)
)

ExampleLineChart.JPG

1 ACCEPTED SOLUTION
aduguid
Super User
Super User

2024_cate_tickets = 
VAR CurrentCount = COUNTROWS (
    FILTER (
        ALL ( 'cate' ),
        'cate'[week_num] <= MAX ( 'cate'[week_num] )
        && 'cate'[date_registered] <= MAX ( 'cate'[date_registered] )
        && 'cate'[event] = "cate 2024"
    )
)
RETURN
    IF(
        ISBLANK(CurrentCount),
        CALCULATE(
            LASTNONBLANK('cate'[week_num], CurrentCount),
            FILTER(ALL('cate'), 'cate'[week_num] < MAX('cate'[week_num]))
        ),
        CurrentCount
    )

View solution in original post

4 REPLIES 4
onedayover
Helper III
Helper III

Hi aduguid, apologies for the delay in getting back to you. You were correct on both counts - I wasn't using a dimension table and the cate table did not contain wk9 data. I fixed this as you outlined and got the graph to display exactly how I needed it to. Thanks again for your help 🙂

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I assume you are not using dimension table, or I assume cate table does not contain wk9 data.

 

Please try using date dimension table.

1. Create date dimension table.

2. Create a relationship between date dimension table & cate table

3. Use x-axis from date dimension table

4. In the measure, input column names from date dimension table.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

aduguid
Super User
Super User

2024_cate_tickets = 
VAR CurrentCount = COUNTROWS (
    FILTER (
        ALL ( 'cate' ),
        'cate'[week_num] <= MAX ( 'cate'[week_num] )
        && 'cate'[date_registered] <= MAX ( 'cate'[date_registered] )
        && 'cate'[event] = "cate 2024"
    )
)
RETURN
    IF(
        ISBLANK(CurrentCount),
        CALCULATE(
            LASTNONBLANK('cate'[week_num], CurrentCount),
            FILTER(ALL('cate'), 'cate'[week_num] < MAX('cate'[week_num]))
        ),
        CurrentCount
    )

Hi aduguid,
Thank you for your reply.
I just tried your code and it the graph didn't change. Do you have any further suggestions?
Thanks

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.