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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Random Values Aggregation

Hi,

 

I hope everyone is doing well.

 

I am generating two random numbers as follows:

Measure1 = var a = Calculate(Rand()*10) return a

Measure2 = var b = Calculate(Rand()*20) return b

whenever i try to subtract these numbers e.g.

Measure3 = Measure1 - Measure2

or

Measure3 = var c =Calculate(Measure1 - Measure2) return c

 

It doesnot give me the right answer.

Please help

 

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Anonymous 

Since you use RAND function, it always generates a new number at the time computation. It doesn't store the values and its  not static.
Let me know what you are trying to achieve.

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

7 REPLIES 7
AllisonKennedy
Community Champion
Community Champion

I'm also not sure what your end goal is, but you may find it useful to create or insert parameters in Power BI Desktop using the built in button or the GENERATESERIES DAX to then create slicers and what if analysis:
https://www.youtube.com/watch?v=a3Wn5s56mgo

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Hi @AllisonKennedy ,

 

Yeah, I am trying to do whatif analysis but on random values. It is not producing the right results.

 

shli.PNG

As you can see the result(EBIT0) is not correct.

Formula: 

EBIT0 = [Vdp0_rand]-[Cons0_rand]-[Cserv0_rand]-[Clav0_rand]-[Gbt0_rand]-[Amm0_rand]

Vdp0_rand = RAND()*([Vdpmax0]-[Vdpmin0])+[Vdpmin0]
Vdpmax0 = (1+SELECTEDVALUE(maxVdp0[maxVdp0]))*SUM(Input[Vdp0])
Vdpmin0 = (1+SELECTEDVALUE(minVdp0[minVdp0]))*SUM(Input[Vdp0])
maxVdp0 = GENERATESERIES(-1, 1, 0.01)
 

 

 

Hi @Anonymous ,

 

If you make sense, can you please accept the helpful answers as solution? Others who have the same questions will find answers esily and quickly. They will benefit from your thread. 😉

 

 

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

Are you able to use slicers instead of Rand()?

As @Fowmy mentioned, RAND is volatile function and recalculates not always as you would expect.

To see if that is the problem, please try adding a test measure as a value to the matrix in your screenshot:

RandCalcTest = [Vdp0_rand]


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Pragati11
Super User
Super User

HI @Anonymous ,

 

Can you share more detail here why you think this is wrong?

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

amitchandak
Super User
Super User

@Anonymous , what is the problem?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Fowmy
Super User
Super User

@Anonymous 

Since you use RAND function, it always generates a new number at the time computation. It doesn't store the values and its  not static.
Let me know what you are trying to achieve.

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.