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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
petermb72
Helper III
Helper III

Get last Number from the last Date Per Location

I know that more than likely has been asked before, I am terrable at seaching for what I am looking for.  I have three locations, I want the last date data was entered for each of the locations.  Here is what the raw data looks like:

DateLocationNumber
1/1/2020Fargo

10

1/2/2020Fargo15
1/1/2020West Fargo100
1/2/2020West Fargo105
1/3/2020West Fargo

106

1/1/2020Moorhead

1000

1/3/2020Moorhead

1001

 

What I would like to see is:

DateLocationNumber
1/2/2020Fargo15
1/3/2020West Fargo106
1/3/2020Moorhead1001
   
   

 

When I am graphing this data and I did not get a submission from one of the locations, I would just like to have the graph just use the last available data point rather than just going to zero or causing an error.  I have been using a filter on the graph by only including data in the last 24 hours but it leaves a blank when when no data has been entered in the last 24 hours.  So there is probably many ways to fix this, I am up for any of them, I just want to not have my graphs show blank when data has not been entered.

 

Thanks,

Peter

1 ACCEPTED SOLUTION

Replace my Last Amount measure with this:

CALCULATE(
    SUM('Table'[Number]),
    VALUES('Table'[Location]),
    FILTER(
        'Table',
        'Table'[Date] = [Last Date]
    )
)

edhans_0-1601330570793.png

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

10 REPLIES 10
edhans
Super User
Super User

Hello @petermb72

You'd need two measures. Here's what I got:

edhans_0-1601309283040.png

The last date is:

Last Date = 
CALCULATE(
    MAX('Table'[Date]),
    ALLEXCEPT('Table', 'Table'[Location])
)

y Last Amount es:

Last Amount = 
MAXX(
    FILTER(
        'Table',
        'Table'[Date] = [Last Date]
    ),
    'Table'[Number]
)

You would probably want to turn off totals in the table visual, as the totals I've shown are probably not significant, but maybe they are if you want an overall total regardless of location.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

YES! that did the trick doing it in two measures.  Thank you for your help and quick reply.  

Glad to be of assistance @petermb72 

Hope the rest of your project goes well.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

A bit of a snag.  When I do a card and try to get a grand total, I am getting a total that incorrect.  It is not the grand total.  What can  I do to get that to work correctly?

I'll have to redo it. I deleted my file aready.

 

But what is the right total, and how logically would I arrive at that? 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

I would expect the total to be 15+106+1001 for a total of 1122

The number I am getting in the card is 1001 (the total from Moorhead for the 3rd.).  It is missing West Fargo on the 3rd as well as Fargo from the 2nd. strange

Replace my Last Amount measure with this:

CALCULATE(
    SUM('Table'[Number]),
    VALUES('Table'[Location]),
    FILTER(
        'Table',
        'Table'[Date] = [Last Date]
    )
)

edhans_0-1601330570793.png

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

PERFECT!

Sorry about that, It looked like it was working perfectly until I tried to get a grand total on a card.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.